Share » Forums » Developer » Modify contents of an attribute when...

Modify contents of an attribute when a button is pressed

Modify contents of an attribute when a button is pressed

Sunday 01 May 2011 6:07:54 am - 6 replies

Author Message

Marko Žmak

Sunday 01 May 2011 2:49:17 pm

In the default eZP installation you don't have the possibility to edit only one attribute. The alternatives are:

  • create an extension with a custom module that does this (or try to find if such an extension already exists)
  • use a form that has hidden fields for all attributes except the one you want to change

The same issue was also discused here:

  • http://share.ez.no/forums/setup-design/object-relations-attribute

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Monday 02 May 2011 1:07:48 am

Ok, thanks.

I had tried to create a form with hidden fields to the attribute I want to modify, but it was redirected to the edit template of the object

I didn't know that I have to do it for all attributes of the object.

David Santiso

Monday 02 May 2011 11:16:33 am

My code is this, but it doesn't work. When I click on the submit button it redirect to the edit template of the object without displaying the changes.

<form name="editform" id="editform" enctype="multipart/form-data" method="post" action={concat( '/content/edit/', $node.contentobject_id, '/', $edit_version, '/', $edit_language|not|choose( concat( $edit_language, '/' ), '/' ), $is_translating_content|not|choose( concat( $from_language, '/' ), '' ) )|ezurl}>
  
  <input class="button" type="submit" name="PublishButton" value="{'Submit'}" />
  <input type="hidden" name="DiscardConfirm" value="0" />

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute1.id}" />
  {attribute_edit_gui attribute=$node.data_map.attribute1 view_parameters=$view_parameters}

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute2.id}" />
  {attribute_edit_gui attribute=$node.data_map.attribute2 view_parameters=$view_parameters}
  
  ...

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute_to_edit.id}" />
  <input type="text" name="ContentObjectAttribute_data_integer_{$node.data_map.attribute_to_edit.id}" value="23" />
            
</form>

Marko Žmak

Monday 02 May 2011 12:17:18 pm

For the attributes you want hidden you don't use attribute_edit_gui but a pair of hidden inputs. And don't forget to do this for all the attributes of the object.

And for the attribute you want to be displayed and edited you do use attribute_edit_gui.

See the other post I mentioned for details.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Monday 02 May 2011 12:45:56 pm

Yes I've read it. I've also tried this, but still not working.

<form name="editform" id="editform" enctype="multipart/form-data" method="post" action={concat( '/content/edit/', $node.contentobject_id, '/', $edit_version, '/', $edit_language|not|choose( concat( $edit_language, '/' ), '/' ), $is_translating_content|not|choose( concat( $from_language, '/' ), '' ) )|ezurl}>
            
  {include uri='design:content/edit_validation.tpl'}
            
  <input class="button_green" type="submit" name="PublishButton" value="{'Submit'}" />
  <input type="hidden" name="DiscardConfirm" value="0" />
            
  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute1.id}" />

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute2.id}" />
  
  ...
        
  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute_to_edit.id}" />
  {attribute_edit_gui attribute=$node.data_map.attribute_to_edit view_parameters=$view_parameters}
            
</form>

Marko Žmak

Monday 02 May 2011 1:00:37 pm

When you use attribute_edit_gui you musn't use the ContentObjectAttribute_id[] input.

Also for every hidden attribute you have to have two input fields as I described in the other post.

Read my answers to the other post more carefully.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu