⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

callback_fields and set_rules ( or required_fields) not working togethere



Paul Savostin
  • profile picture
  • Member

Posted 01 May 2014 - 17:10 PM

Hi everybody!

Question is title of post

Example:

->fields(....,'custom_field',...)

....

->callback_field('custom_field',array($this,'_custom_field_callback'))

....

public function _custom_field_callback($value = null){
       
        //exmaple

        $value = 'some value';

        return '<input type="text" maxlength="50" value="'.$value.'" name="name" style="width:462px">';
    }

....

 And if ->set_rules('custom_field','','callback_validation_custom_field') ( required_fields not working too)

....

public function validation_custom_field($value){
       
        HERE $value EMPTY EVERYTIME but on the page in that field value present !!!

        $value = trim($value);
        if(empty($value)){  
           $this->form_validation->set_message(__FUNCTION__,lang('custom error message'));
          
           return FALSE;
          }else{
           return TRUE;
          }
    }

Any help?

Thanks

 


Paul Savostin
  • profile picture
  • Member

Posted 02 May 2014 - 17:04 PM

If you want to recieve answers you should born a girl...


Paul Savostin
  • profile picture
  • Member

Posted 07 May 2014 - 20:18 PM

Well I finally resolve the problem! Point is that everywhere i need the same  field name - in callback_field('custom_name',....), in fields list ->fields(..., 'custom_name',..) , in set_rules('custom_name') and input tag must have
attribute with name='custom_name'. And now everything OK