It is currently Mon Jan 22, 2018 12:02 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Disable field validation when a field has display => 0
PostPosted: Tue Mar 04, 2008 6:03 pm 
Offline

Joined: Fri May 25, 2007 9:26 pm
Posts: 9
I noticed a little issue which may or may not be considered a clonefish bug.

When I dynamically build a form, sometimes an element is required and has some validation... but other times I do not include the field at all by doing a display => 0.

Anyways, I've made a little patch to clonefish.php which is meant to disable validation on fields with display => 0.

Looking at the start of getValidationJSCode() in clonefish.php,


Code:
    foreach ( $this->elements as $key => $object ) {
     
      // a little patch so that if objects are not displayed, their validation code is not run.
      if (!$object->display) { break; }


Please let me know if you think this patch is not a good idea / breaks stuff / doesn't do what I intend / etc.

Thanks again

Jason

p.s. I keep loving clonefish


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 04, 2008 6:28 pm 
Offline

Joined: Fri May 25, 2007 9:26 pm
Posts: 9
Doh, I don't think this will work... I just realized that I have lots of fields with display => 0 that are used in templates, and still require validation.

I guess I'll have to figure out another solution


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 04, 2008 7:39 pm 
Offline
Site Admin

Joined: Thu Jan 19, 2006 2:38 pm
Posts: 105
Hi Jason,

If I understand correctly, in some cases you absolutely don't need several elements in the form. The best you can do in such a situation is simply unsetting the element in question instead of setting its <code>display</code> to <code>0</code>. The <code>display</code> attribute is intended to be used only with templating, that's why it was designed the way you've just realized!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group