Skip to main content
deleted 5 characters in body; edited title
Source Link
AnD
  • 675
  • 1
  • 11
  • 28

I don't want ajax submit / callback validate form '#required' => TRUE,

I have form with static fields and dynamic fields as follow:

fieldset

  1. textfield00 (require = true)
  2. textfield01 (require = true)

fieldset

  1. textfield02

fieldset

  1. add textfield

  2. submit button

so, everytime add textfield pressed, it will add new/duplicate textfield02.

with add textfield code as follow:

$form['fields']['modules']['add'] = array(
      '#type' => 'submit',
      '#name' => 'addtextfield',
      '#value' => t('Add more TextField'),
      '#submit' => array(array($this, 'addTextfieldSubmit')),
      '#ajax' => array(
        'callback' => array($this, 'addTextFieldCallback'),
        'wrapper' => 'wrapper',
        'effect' => 'fade',
      ),
    );

the adding field is working fine, the only problem i have here is: because textfield00 and textfield01 is mandatory, if i pressed add button, it will send me an error message 'mandatory fields' before i can add new textfield.

so how can i 'bypass' the requried validation, everytime i press add textfiled and only validate 'required = true' only when i press submit button.

Thank You, AnD

I don't want ajax callback validate form '#required' => TRUE,

I have form with static fields and dynamic fields as follow:

fieldset

  1. textfield00 (require = true)
  2. textfield01 (require = true)

fieldset

  1. textfield02

fieldset

  1. add textfield

  2. submit button

so, everytime add textfield pressed, it will add new/duplicate textfield02.

with add textfield code as follow:

$form['fields']['modules']['add'] = array(
      '#type' => 'submit',
      '#name' => 'addtextfield',
      '#value' => t('Add more TextField'),
      '#submit' => array(array($this, 'addTextfieldSubmit')),
      '#ajax' => array(
        'callback' => array($this, 'addTextFieldCallback'),
        'wrapper' => 'wrapper',
        'effect' => 'fade',
      ),
    );

the adding field is working fine, the only problem i have here is: because textfield00 and textfield01 is mandatory, if i pressed add button, it will send me an error message 'mandatory fields' before i can add new textfield.

so how can i 'bypass' the requried validation, everytime i press add textfiled and only validate 'required = true' only when i press submit button.

Thank You, AnD

I don't want ajax submit / callback validate form '#required' => TRUE,

I have form with static fields and dynamic fields as follow:

fieldset

  1. textfield00 (require = true)
  2. textfield01 (require = true)

fieldset

  1. textfield02

fieldset

  1. add textfield

  2. submit button

so, everytime add textfield pressed, it will add new/duplicate textfield02.

with add textfield code as follow:

$form['fields']['modules']['add'] = array(
      '#type' => 'submit',
      '#name' => 'addtextfield',
      '#value' => t('Add more TextField'),
      '#submit' => array(array($this, 'addTextfieldSubmit')),
      '#ajax' => array(
        'callback' => array($this, 'addTextFieldCallback'),
        'wrapper' => 'wrapper',
        'effect' => 'fade',
      ),
    );

the adding field is working fine, the only problem i have here is: because textfield00 and textfield01 is mandatory, if i pressed add button, it will send me an error message 'mandatory fields' before i can add new textfield.

so how can i 'bypass' the requried validation, everytime i press add textfiled and only validate 'required = true' when i press submit button.

Thank You, AnD

Source Link
AnD
  • 675
  • 1
  • 11
  • 28

I don't want ajax callback validate form '#required' => TRUE,

I have form with static fields and dynamic fields as follow:

fieldset

  1. textfield00 (require = true)
  2. textfield01 (require = true)

fieldset

  1. textfield02

fieldset

  1. add textfield

  2. submit button

so, everytime add textfield pressed, it will add new/duplicate textfield02.

with add textfield code as follow:

$form['fields']['modules']['add'] = array(
      '#type' => 'submit',
      '#name' => 'addtextfield',
      '#value' => t('Add more TextField'),
      '#submit' => array(array($this, 'addTextfieldSubmit')),
      '#ajax' => array(
        'callback' => array($this, 'addTextFieldCallback'),
        'wrapper' => 'wrapper',
        'effect' => 'fade',
      ),
    );

the adding field is working fine, the only problem i have here is: because textfield00 and textfield01 is mandatory, if i pressed add button, it will send me an error message 'mandatory fields' before i can add new textfield.

so how can i 'bypass' the requried validation, everytime i press add textfiled and only validate 'required = true' only when i press submit button.

Thank You, AnD