[Maypole] 2.07 PR
Dave Howorth
dhoworth@mrc-lmb.cam.ac.uk
Tue, 18 Jan 2005 09:37:24 +0000
Dave Howorth wrote:
> Simon Flack wrote:
>>> BUT on the list page it also appears to cause search parameters to be
>>> transferred to the addnew box after pressing 'search'. This seems wrong.
>>
>> I noticed that, and I thought I'd fixed it by cloning the
>> HTML::Element returned by classmetadata.cgi.$col:
>> SET elem = classmetadata.cgi.$col.clone;
>> Do you have that line in your 'addnew' template?
>
> That'll be what that line was for, then :) Sorry. I'll try it tomorrow.
I tried it but I still see the same symptom. Looking at the URL after my
search, I don't understand how cloning the element would stop the
request parameters matching?:
http://localhost/cgi-bin/qd1.cgi/coords/search/?id=&name=gi&bio_database_id=&search=search
My custom/addnew.tt is different to the factory/addnew of course. Here
it is in case there's some other significant difference:
[%- table = classmetadata.table -%]
<div id="addnew">
<form method="post" action="[% base %]/[% table %]/do_edit/">
<fieldset>
<legend>Add a new [% tables.$table.singular %]</legend>
[% USE model = Class(classmetadata.name) ;
FOR col = classmetadata.columns ;
NEXT IF columns.$table.$col.primary %]
<label>
<span class="field">[% columns.$table.$col.singular %]</span>
[% elem = model.to_field(col).clone ;
param = request.param(col) ;
IF param ;
IF elem.tag == 'textarea' ;
elem = elem.push_content(param) ;
ELSE ;
elem.attr("value", param) ;
END ;
END ;
elem.as_XML ;
-%]
</label>
[% IF errors.$col %]
<span class="error">[% errors.$col %]</span>
[% END ;
END %]
[% IF errors.FATAL %]
<span class="error">[% errors.FATAL %]</span>
[% END ; %]
<input type="submit" name="create" value="create"/>
</fieldset>
</form>
</div>
Cheers, Dave