欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Custom 'Node add/edit form' doesnt't publish unless 'General Form' item is exposed to user. 有大用

当用户是管理员时 

设置 已发表 推荐到首页 表单中隐藏关于文章的 各种 Vertical tabs 时,就会是未发布,未置顶

我的办法是 创建一个 rules 让新建或保存文章时 让它已发布 已置顶

image.png                    


                   

image.png                    

image.png                        

Within Pages, I have enabled the "Node add/edit form" and built a new node creation form for a custom content type.

I have added form fields content including "Node form submit buttons" and on my new "Node add/edit form" I see one button: "Save".

Problem: After I click Save, the node is not published. I would like the node to be published.

Settings:
                       The content type has the correct permissions set to allow me to publish content.

In the content type settings, I have set Publishing options to default = published.

Observation:
                       If I add the (unwanted) "General Form" item to my custom "node edit/add form" then when I click save on node creation, the content is also published.


Comments

   
merlinofchaos’s picture        

Status:Active» Fixed

This is the expected behavior.

If you do not add the general form, you do not get necessary widgets for the form that are very important. With those widgets absent, the code that drives the form does not know how to process them, and no default values are set. The way Form API works, there is no way to make this happen.

Panels cannot remove elements, it can only arrange them. If you want to remove elements you must use hook_form_alter

   
damban’s picture        

Ah, too bad. Thanks for the reply though. Now I'm stumped.

I then need a way to build a custom node/edit page that includes the general form, and yet hides it from user view.

   
merlinofchaos’s picture        

You would need to implement hook_form_alter on that form and set #access = FALSE on the elements you want to hide.

   
rogical’s picture        

this page is not using styling forms, but add related components, such as custom navigations, breadcrumb, helps etc.

   

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

   
fedegf’s picture        

*** Sorry, not correctly tested before posting ***
                           *** I left it here. Maybe someone will take the idea and make it work... ***

Hello,

in case someone else is interested in this feature, I have found a way to do it.

My problem was the original that damban posted: I want the content type Foo to be published when edited/saved by an authorized user _without_ administrator verification and I am using Node template by Panels. Even if default Publish option is "publish", the content does not publish after editing/saving.

Solution: I added General form to the node template, then add a Visibility rule and set a rule that is impossible to be true (I chose "user:role" and left all unchecked). The general form will never be shown, but the information will be there, so the Publish status will change as defined in the content type.

I hope that I have understood your problem and explained my solution correctly.

   
damban’s picture        

@fedegf, a year later and I am able to work on this project again. You solution so far has worked perfectly. I simply used current theme, and set it to one I am not using. The General Form is no longer visible.

   
dojorob76’s picture        

In my case, using form fields (instead of General Form) in Page Manager only publishes content for non-admin users.

So, if an admin creates content with one of the Page Manager node/%/edit forms, it will be created, but not published. However, if anyone else (with 'create new content' permissions) creates content on the same form, it is created and published... which I find very, VERY strange.

Meanwhile, adding the general form to the page and making it invisible did not help in my case. Admin content still gets created but not published.

I am using Drupal 7.23, cTools 7.x-1.3+4-dev and Panels 7.x-3.3 with PHP 5.3.27

Thoughts?

   
bobgeier’s picture        

Issue summary:View changes                                    

@dojorob76, I can confirm that behavior. Non-admin users are able to add/edit and publish, Admin users are not.

The simplest workaround I've found is to just place the Publishing Options pane as visible only to the administrator's role, and then hide that element in CSS.

   
fluxline’s picture        

i found this after i stopped using drupal 6 or 7 years ago and going back to just doing things by hand because it was always some unforeseen thing that took hours to track down, because drupal is just about 90% there and then there is some hook or other that needs to be coded to get it the way it should be. i only came back to use drupal, to set it up for a colleague to have a platform he could change.

this is a perfect example, who would expect that you want to customise the node edit form, and then use that customisation to edit a node and have a published node change it's status to not published. merlin, you've done some great things for drupal, but this is such a non intuitive behaviour and the default could have been set for what most would expect. it looks almost intentional. this is what turns people off of drupal and gives it the reputation of a steep learning curve. much is learning but mush is not learning, it is unnecessary complication. yes, it's free, i know.

   
NWOM’s picture        

As a workaround, just add the Publishing Options form element as you would normally, and then use theSimplify                            module to hide it.

This gives you the ability to hide the options from the panel and still publishes the node since it is pre-selected in the Content Type settings.

   
fledev’s picture        

Even if a old issue I had to add my support.
                           @fluxline: You just expressed my thoughts.
                           @merlinofchaos: great work, contribution, I take my hat down in front of you. But don't forget that behind all of this there has to be a flexible and user friendly usability.



来自  https://www.drupal.org/project/panels/issues/1648250

普通分类: