CodeIgniter Forums
Form Generation Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Form Generation Library (/showthread.php?tid=16439)



Form Generation Library - El Forum - 05-17-2012

[eluser]sock[/eluser]
Thanks for the suggestion, but I need to have a break after each label, not after the entire group.

Would be nice to maybe even switch on the fly for 2 groups to have different config items applied to them within the same form (prefix/suffix).

What I'm getting:

Code:
Please Select:        [ ] Option A   [ ] Option B    [ ] Option C

What I would like:

Code:
Please Select:
[ ] Option A
[ ] Option B
[ ] Option C

And either change the label_suffix on a per form or per call basis. Think I'm just missing something.


Form Generation Library - El Forum - 05-17-2012

[eluser]sock[/eluser]
I'm sure the question I asked previously can be done through CSS, but I'm trying to avoid that (why? I don't know).

One thought I had was, for example we have in our config/form.php:

Code:
$config['label_suffix']  = '';

If we added an argument (optional to not break previous code) to something like checkgroup:

Code:
From
checkgroup (string name, array $checks [, string label, string|array checked, string rules, string|array attributes])

To

checkgroup (string name, array $checks [, string label, string|array checked, string rules, string|array attributes, string|array override])

->checkgroup('Example', $example, 'Please select:', $selectedItems, '', '', array('label_suffix' => '<br />'))

That would then override anything in the config file with what is supplied in the override string/array. Time to look in the libraries/Form.php I guess.



Form Generation Library - El Forum - 06-06-2012

[eluser]Michael L.[/eluser]
I have there problems too.
Need to wrap lable and input-radios into a UL with LI elements
UL
LI
INPUT radio
LABLE
/LI
...
/UL

i tryed changes in the config and there ist some bug with the pre and suffixes
Code:
$config['group_prefix']  = '';  // wraps around checkgroups and radiogroups
$config['group_suffix']  = '';
$config['element_prefix']  = '<div>';  // wraps around all elements
$config['element_suffix']  = '</div>';
$config['label_prefix']  = '';  // wraps around labels
$config['label_suffix']  = '';
$config['field_prefix']  = '';   // wraps around fieldsets (inside), inputs, buttons, textareas, selects, captchas & recaptchas
$config['field_suffix']  = '';

i'm getting this. it look like the suffix is missing every time
Code:
&lt;form action="http://ci/index.php/signup" accept-charset="utf-8" class="formee" name="signup_step1" id="signup_step1" method="post"&gt;&lt;div><fieldset>
<legend>Some Inputs</legend>

<div>&lt;input type="radio" name="account_type[]" value="A" class="check" id="e099f"  /&gt;&lt;label for="e099f" class="left check">lable A</label>
<div>&lt;input type="radio" name="account_type[]" value="B" class="check" id="fae2f"  /&gt;&lt;label for="fae2f" class="left check">lable B</label>
</fieldset>
&lt;/form&gt;


Form Generation Library - El Forum - 06-25-2012

[eluser]macigniter[/eluser]
Quote:New version 2.0.2 available!
Please read the changelog before downloading and upgrading



Form Generation Library - El Forum - 06-26-2012

[eluser]paulo_cv[/eluser]
I have a question about this great code, I hope somebody can help me. I read the user guide but couldn't find anything related.

I have one field with two validations:

->text('nombre', 'Nombre' ,'required|numeric')

I would like to set custom error messages for each one of these validations, based on a couple of tests that I did I assume that if I set two set_error lines they will be assigned in the same order as in the assignment above:

->set_error('nombre', 'The field is required, please enter a value')
->set_error('nombre', 'Only numbers are allowed')

The assumption that I made about the order of the messages seems to work ok but I'd like clarification if that is how it's supposed to be done.

And the second "issue" is that if I try to submit the form without populating a value the numeric validation kicks in instead of the required. In other words if I click on Submit without a value the error message will be "Only numbers are allowed" instead of "The field is required ..."

Any help will be greatly appreciated.



Form Generation Library - El Forum - 06-27-2012

[eluser]gmatkowski[/eluser]
Hi,
i have a small problem with this library, the thing is:
I have two forms on one page, no matter what i do (changing text fields names, form names etc.) after submiting form the library validates both forms and throw errors ... can anyone tell why this is happening ?

Forms have different names, even submit buttons have.

Code:
public function regForm()
{
  $this->form->config['element_prefix']  = '<p>';
  $this->form->config['element_suffix']  = '</p>';
  

  $this->form->clear();
  $this->form
  ->open(current_url(), 'employers-reg-form', array('class'=>'employer-form'))

  ->text('employers_name', 'Nazwa firmy:', 'required|trim|xss_clean','')
  ->text('employers_first_name', 'Imię:', 'required|trim|xss_clean','')
  ->text('employers_last_name', 'Nazwisko:', 'required|trim|xss_clean','')
  ->text('employers_email', 'Adres email:', 'required|valid_email','')
  ->password('employers_password', 'Hasło:', 'required|trim|xss_clean','')

  ->button('Zarejestruj', 'submit-reg', 'submit')

  ->validate();

  if($this->form->valid)
  {
   $post = $this->form->get_post();

   redirect(site_url('strefa-pracodawcy'));
  }
  
  return $this->form->get();
}

public function logForm()
{
  $this->form->config['element_prefix']  = '<p>';
  $this->form->config['element_suffix']  = '</p>';
  

  $this->form->clear();
  $this->form
  ->open(current_url(), 'employers-log-form', array('class'=>'employer-form'))

  ->text('employers_email', 'Adres email:', 'required|valid_email','')
  ->password('employers_password', 'Hasło:', 'required|trim|xss_clean','')

  ->button('Zaloguj', 'submit-log', 'submit')

  ->validate();

  if($this->form->valid)
  {
   $post = $this->form->get_post();

   if(!$this->employers_model->log($post['employers_email'],$post['employers_password']))
   {
    $this->form->add_error('username', 'logowanie niepoprawne!');
   }
   else
   {
    redirect(site_url('strefa-pracodawcy'));
   }
  }
  
  return $this->form->get();
}

public function log()
{
  if($this->employers_model->isLogged())
  {
   redirect(site_url('strefa-pracodawcy'));
  }
  

  $data = array(
  'formLog' => $this->logForm(),
  'formReg' => $this->regForm()
  ) ;

  $this->load->view('log_view',$data);
}



Form Generation Library - El Forum - 06-27-2012

[eluser]gmatkowski[/eluser]
Problem solved ... fields names cannot be doubled, no matter what (forms names, buttons names) ...


Form Generation Library - El Forum - 06-27-2012

[eluser]paulo_cv[/eluser]
I have decided to delete the set_error lines and customize the general error messages in the language packs.


Form Generation Library - El Forum - 07-06-2012

[eluser]Unknown[/eluser]
Small bug, bugging me for days.
Hidden form field doesn't get an ID, even with nameasid set.
I can't figure out where it's lost.

On visible fields, id is created correctly.

TIA.



Form Generation Library - El Forum - 07-28-2012

[eluser]drewbee[/eluser]
Hi.

When the value of $config['error_class'] = ''; (an empty string), the following error on the form is thrown:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: El::$error_class

Filename: libraries/Form.php

Line Number: 533

Backtrace:

File: C:\wamp\www\public\tutorialhivemind\www\application\libraries\Form.php
Line: 533
Function: _exception_handler

File: \libraries\Form.php
Line: 611
Function: _make_label

File: \libraries\Form.php
Line: 794
Function: password

File: \libraries\Form.php
Line: 2204
Function: get

File: \libraries\Form.php
Line: 1562
Function: _elements_to_string