Welcome Guest, Not a member yet? Register   Sign In
Form Generation Library

[eluser]ckm5[/eluser]
I'm trying to remove the reset/cancel button. I deleted the custom reset, but now there is a 'cancel' button appearing I didn't spec anywhere.

Here's my code:

Code:
$this->form
   ->fieldset('My Form')
   ->text('existing','Existing Value','max_length[2]|numeric',$this->session->userdata['existing_value'],'readonly="readonly"')
   ->text('new_value', 'Update Value', 'required|max_length[2]|numeric')
   ->indent(150)
   ->html('<a href="/allowed_values" target="_blank">Allowed Values (new window)</a>')
   ->br()
   ->br()
   ->submit('Update Values');
  
   $output['form'] = $this->form->get();
                        $this->load->view('values_manage', $output);

And the view (values_manage.php) looks like this:

Code:
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
<div id="wrapper">
<div id="content">


<h1>Values</h1>

&lt;?php echo $errors?&gt;
&lt;?php echo $form?&gt;

<br /><br />

</div>
</div>
&lt;/body&gt;
&lt;/html&gt;

Note: I had mis- top-posted this because of the crappy UI/organization of the CI forums... Reposting it here where it belongs.

Thx.

Chris.

[eluser]ash0803[/eluser]
I have a few questions which can hopefully be quickly sorted.

- Is there a way to add attributes to the form element namely the class attribute.

- I am using this tool with Bootstrap so I am messing a lot with the prefixes and suffixes. However, some forms on my website will be displayed differently so would require different wrappers to before. Is there a way to load different config files or dynamically change what the suffixes or prefixes are? Would it be possible to set them from inside the actual declaration?

Many thanks

Ash

[eluser]timobg[/eluser]
Just downloaded the new version and found a small bug. The library doubles the prefixes and suffixes from the config file.

In the library, they are appended twice - ex. with "label" - once in the
Code:
function _make_label($pos='')
and second time in the
Code:
function label()

Anyway, the library is great

Thanks for sharing!

[eluser]Michael L.[/eluser]
Hello, ich found a small bug. add_error method doesn't adds the error to error_array!
The erros from the elements(fields) are put into the error_array in the validation method, and the model is called after validation is passed, so the add_error method used like mentions in the guide within the model never gets the custom set error into the error_array. the error string and form->valid (to FALSE) are set correctly.

[eluser]Jan_1[/eluser]
Did not find placeholder in 2.0.2-Download?!
Have put it in library form.php line 1135
Code:
function text($nameid, $label='', $rules='', $value='', $atts=array(), $placeholder='')
{
  $info = $this->_make_info($atts);
  ...
        $info['placeholder'] = $placeholder;
...
  $this->add($info);
  return $this;
}

[quote author="macigniter" date="1236361436"][quote]
New version 2.0.2 available!

[eluser]paul-s-[/eluser]
I am trying to add attributes to the element only by defining an array as per the user guide. The attributes are getting added to the element as expected but some of the attributes in the array are also getting added to the label.

e.g. using a little test date the controller is:
Code:
$attributes=array('data-type'=>'toggle','class'=>'foo bar ','placeholder'=>'firstname','type'=>'email');
$this->form->text('email','Email','trim','',$attributes);

Which outputs the following HTML:
Code:
<label for="email" class="foo bar" data-type="toggle">Email</label>
&lt;input type="text" name="email" value="" data-type="toggle" class="foo bar" placeholder="firstname" autocomplete="off" id="email"  /&gt;

You can see that the "data-type" and "class" get added to the label - but the others don't and having the "class" applied to the label is causing layout issues.

Is there a way to apply the attributes only to the element as per the manual - what am I doing wrong?

== UPDATE ==

Sussed it. The manual is a little confusing (for me anyway) in that it says "supply a string or an associative array with attributes. However whiilst this didn't work
Code:
$attributes=array('data-type'=>'toggle','class'=>'foo bar ','placeholder'=>'firstname','type'=>'email');

a comma-separated STRING version does : "

Code:
.....,'class=foo bar, placeholder=firstname, data-type=toggle');

[eluser]Damir Sivic[/eluser]

[eluser]quickshiftin[/eluser]
Very cool!

[eluser]Unknown[/eluser]
Hi there,

I'm having an issue with the validation for the radiogroup element.

Code:
$copy_create[] = array('1', 'Create a new structure');
$copy_create[] = array('2', 'Create a copy of an existing structure');

->radiogroup('copy_or_create', $copy_create, 'Copy or create?', '', 'required')

What I am getting is a message: (The Copy or create? field is required.) this is correct, but the error class is being added to the second radio label (Create a copy of an existing structure) and not the original label (Copy or create?).

How do I get the error class added to the original label either as well or along with the other labels for this radiogroup?

Any suggestions would be gratefully received.

Rich




Theme © iAndrew 2016 - Forum software by © MyBB