Forums / Setup & design / Manually choose which attributes to edit

Manually choose which attributes to edit

Author Message

Roy Bøhmer

Thursday 29 July 2004 2:06:23 am

Hi!
Lets say I've made a class with 2 attributes: name (textline) and email (email). The email-attribute is required.
Now I want anonymous users to make new objects of this class. This is no problem when using code like

{include uri="design:content/edit_attribute.tpl"}

But how do I write the code if I only want the useres to fill in ONLY the email-attribute? In other words: I dont want them to be presented to a textline where they have to fill in their name.
I've tried to find the golden documentation page on how to make the form manually, but with no luck.

The html-output is something like

<input type="hidden" name="ContentObjectAttribute_id[]" value="785" />
<input class="" type="text" size="40"  name="ContentObjectAttribute_ezstring_data_text_785" value=""  />

and I think the name="..." is my problem. But how to make it dynamic?

Thanks!
Roy

Paul Forsyth

Thursday 29 July 2004 2:47:38 am

Try this:

If you are editing something then the varaible $content_attributes will be. You need to select the correct attribute to make this work...

<form>
{let email_attribute=$content_attributes[1]}

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

<input type="submit" name="PublishButton" />
<input type="submit" name="CancelButton" />

{/let}

</form>

Hope this helps

paul

--
http://www.visionwt.com

Roy Bøhmer

Thursday 29 July 2004 5:52:30 am

Aaah! Thanks! Things are getting clearer.
But this means the user has to press some kind of Edit or New-button first. I would like to have the form present all the time, much like the search-form (even if my first post didn't tell). The intention is to make it easy for people to subscribe to a newsletter. But if my "clear" understanding is right I have to make a content/edit-call before I will be able to publish new objects, or..?

Roy

Paul Forsyth

Thursday 29 July 2004 6:01:37 am

If you are creating new objects a call to content/edit is the best way to go. If you are making any kind of form submit you always need a way of making the form submit, so buttons (of whatever form) are needed :)

It sounds like you want something like kernel/content/tipafriend.php. Have a look at how this code works, passes information from the html to the php underneath. Objects can then be created as you need.

paul

Roy Bøhmer

Thursday 29 July 2004 6:51:57 am

Thank you. I'll look into the tip-a-friend stuff soon. I've also made a module in order to send SMS, so I might just do some adjustments to make it create new objects. Wonder why I didnt think about doint it in php before. Well, I'll blame it on the fact that everybody else is on vacation and I still sit here :-)

Brendan Pike

Sunday 31 October 2004 7:09:17 pm

I'm quite interested to know what you created regarding the SMS module. I'm wondering if anyone has created a workflow extension to SMS as well as email when triggered.

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.