How to clear a text field (extension configuration)

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

How to clear a text field (extension configuration)

Postby Stingray » Sat Jun 11, 2011 6:45 pm

Alright, I've added a text field to configure further an extension. The default value in this field would be that it is blank. So, I can change the value to something other than 'blank', but I cannot clear it without getting an error message. What do I need to do to get PivotX to allow me to clear the field?

Code:
Code: Select all
    $form->add( array(
        'type' => 'text',
        'name' => 'uaresource_unknownimage',
        'label' => "Custom Unknown OS/Browser Image:",
        'value' => '',
        'error' => '',
        'text' => 'a jTip',
        'size' => 50,
        'isrequired' => 0,
        'validation' => 'ifany|string|minlen=0|maxlen=100'
    ));

I would assume it's something that needs to be changed in the 'validation' key, but what?

Thanks!
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: How to clear a text field (extension configuration)

Postby Harm10 » Sat Jun 11, 2011 11:39 pm

A while ago I also had a discussion with hansfn about this.
It turns out that if you leave out string then it works as you want it to work.
This only happens with string and not with integer for example.
So try this
Code: Select all
'validation' => 'ifany|minlen=0|maxlen=100'

If you use another minlen you can still clear the field.
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: How to clear a text field (extension configuration)

Postby Stingray » Sun Jun 12, 2011 1:06 am

Thanks, what you suggested worked.

Harm10 wrote:If you use another minlen you can still clear the field.


So something like this would also work?

Code: Select all
'validation' => 'ifany|string|minlen=0|minlen=0|maxlen=100'


Because, honestly, a minimum length of 6, if there's something in the field to begin with, would be ideal, using that above example, could I do something like this?

Code: Select all
'validation' => 'ifany|string|minlen=0|minlen=6|maxlen=100'
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: How to clear a text field (extension configuration)

Postby Harm10 » Sun Jun 12, 2011 10:04 am

I meant another value for minlen...............
So I guess you need this code (leave out string):
Code: Select all
'validation' => 'ifany|minlen=6|maxlen=100'
It should accept a string of minimum length 6 and maximum length 100 and will be clearable.
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)


Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 2 guests

cron