I have an object with a built-in method (called "check_id") for determining whether the value from a retrieved object has the same id as one of the elements in the current object's lines property. What I want to do is make an edit form that has a <SELECT> element with a complete list of object id's of a given type (meta_type = 'Doctrine') and compare each of those id's to the id's stored in the current object's lines property. If there is a match, I want the <OPTION SELECTED> statement written. Otherwise, it would be simply <OBJECT>. Note, the Doctrine object has (of course) an id. The lines property has a list of id's that are subsets of the total number of Doctrine objects. Here is the code... <SELECT NAME="doctrines:list" SIZE="5" MULTIPLE> <dtml-in "objectValues('Doctrine')"> <dtml-if "check_id(sequence-item.id)"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var title></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var title></OPTION> </dtml-if> </dtml-in> </SELECT> The question that I have is that <dtml-if "check_id(sequence-item.id)"> doesn't work. Any hints as to what the problem might be? TIA, Ron
"sequence-item.id" in python means sequence minus item.id. Also, you should use getId and not id. Use this: <dtml-if "check_id(_.getitem('sequence-item').getId())"> Florent Guillaume Nuxeo
complaw@hal-pc.org writes:
I have an object with a built-in method (called "check_id") for determining whether the value from a retrieved object has the same id as one of the elements in the current object's lines property.
What I want to do is make an edit form that has a <SELECT> element with a complete list of object id's of a given type (meta_type = 'Doctrine') and compare each of those id's to the id's stored in the current object's lines property. If there is a match, I want the <OPTION SELECTED> statement written. Otherwise, it would be simply <OBJECT>.
Note, the Doctrine object has (of course) an id. The lines property has a list of id's that are subsets of the total number of Doctrine objects.
Here is the code...
<SELECT NAME="doctrines:list" SIZE="5" MULTIPLE> <dtml-in "objectValues('Doctrine')"> <dtml-if "check_id(sequence-item.id)"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var title></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var title></OPTION> </dtml-if> </dtml-in> </SELECT>
The question that I have is that <dtml-if "check_id(sequence-item.id)"> doesn't work. Any hints as to what the problem might be? You probably have 2 problems:
1. "sequence-idem": you already got an answer... 2. "check_id" will probably look at the wrong object. make the object explicite... Dieter
participants (3)
-
complaw@hal-pc.org -
Dieter Maurer -
Florent Guillaume