Part of the EllisLab Network
   
 
Assoc data
Posted: 23 June 2009 08:50 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  17
Joined  03-23-2009

Hi,

I have a big dinamycally form. I have test with questions and answers data. My $_POST array look like:

array
  
'test' =>
    array
      
'name' => string 'Тест просто тест2' (length=31)
      
'description' => string 'Проверка хрени какой-то )' (length=45)
      
'way_of_result' => string 'numeric' (length=7)
      
'state' => string 'cancelled' (length=9)
  
'question' =>
    array
      
'que_1' =>
        array
          
'text' => string 'Вопрос 1' (length=14)
          
'type' => string 'checkbox' (length=8)
          
'answer' =>
            array
              ...
          
'action' => string 'add' (length=3)
      
'que_2' =>
        array
          
'text' => string 'Вопрос 2' (length=14)
          
'type' => string 'radio' (length=5)
          
'answer' =>
            array
              ...
          
'action' => string 'add' (length=3)
      
'que_3' =>
        array
          
'text' => string 'Вопрос3' (length=13)
          
'type' => string 'textbox' (length=7)
          
'action' => string 'add' (length=3)

, where answer array is:

array
  
'ans_1' =>
    array
      
'weight' => string '101' (length=3)
      
'text' => string 'отв1' (length=7)
      
'action' => string 'add' (length=3)
  
'ans_2' =>
    array
      
'weight' => string '102' (length=3)
      
'text' => string 'отв3' (length=7)
      
'action' => string 'add' (length=3)
  
'ans_3' =>
    array
      
'weight' => string '103' (length=3)
      
'text' => string 'отв5' (length=7)
      
'action' => string 'add' (length=3)


REQUEST:
1) I want to validate my data in arrays. See http://codeigniter.com/forums/viewthread/117694/

$this->form_validation->set_rules('question[que_(:num)][text]', 'lang:question_name', 'required|max_length[100]');
$this->form_validation->set_rules('question[(:num)][text]', 'lang:question_name', 'required|max_length[100]');
$this->form_validation->set_rules('question[(:num)][answer][ans_(:num)][weight]', 'lang:answer_weight', 'required|numeric');
$this->form_validation->set_rules('question[(:num)][answer][(:num)][weight]', 'lang:answer_weight', 'required|numeric');


2) CI wrong parse field names like ‘test[image]’ in form_validation matches method, in do_upload method and other…

$this->form_validation->set_rules('user[password_conf]', 'lang:user_password_conf', 'required|matches[user[password]]');
$this->upload->do_upload('test[image]')

returns ‘You did not select a file to upload.’

 Signature 

Develop web, PDA applications.
My resume http://mdomansky.com/resume/

Contact with me )

Profile
 
 
Posted: 23 June 2009 07:37 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
RankRankRankRank
Total Posts:  1242
Joined  04-19-2008

Shouldn’t you be posting in another part of the forum? Anyway, you’ve just have too check that you’re actually setting the correct rules to the correct(and existing) form fields.

 Signature 

PinoyTech - Web Development Blog

Profile
 
 
Posted: 24 June 2009 06:39 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  17
Joined  03-23-2009

I’ve check it!

My html:

<?= form_open_multipart('test/'.((isset($test)) ? $test->getId().'/' : '').'save', array('method' => 'post', 'id' => 'form-test-save')); ?>

[i][skipped][
/i]

<input type="file" name="test[image]"><br><br>

[i][skipped][/i]

<input type="submit" value="<?= $this->lang->line('submit'); ?>">
<?= form_close(); ?>
 Signature 

Develop web, PDA applications.
My resume http://mdomansky.com/resume/

Contact with me )

Profile
 
 
Posted: 25 June 2009 12:12 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
RankRankRankRank
Total Posts:  1242
Joined  04-19-2008
MDomansky - 23 June 2009 08:50 AM
$this->form_validation->set_rules('question[que_(:num)][text]', 'lang:question_name', 'required|max_length[100]');
$this->form_validation->set_rules('question[(:num)][text]', 'lang:question_name', 'required|max_length[100]');
$this->form_validation->set_rules('question[(:num)][answer][ans_(:num)][weight]', 'lang:answer_weight', 'required|numeric');
$this->form_validation->set_rules('question[(:num)][answer][(:num)][weight]', 'lang:answer_weight', 'required|numeric');

Are you sure? I don’t see these working with the form_validation.

 Signature 

PinoyTech - Web Development Blog

Profile
 
 
Posted: 25 June 2009 06:06 AM   [ Ignore ]   [ # 4 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2519
Joined  06-11-2007

HTML arrays are not supported by the validation library.

 Signature 

Blog | Twitter | GitHub
————————-
CodeIgniter 2: Everything you need to know
————————
PyroCMS - open source modular CMS built with CodeIgniter
CleverAndy - get money for un-used concept designs
————————
Libraries: Asset, Dwoo, Cache, cURL, CLI, REST, Template

Profile
 
 
Posted: 01 July 2009 05:20 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Avatar
Total Posts:  17
Joined  03-23-2009
bargainph - 25 June 2009 12:12 AM
MDomansky - 23 June 2009 08:50 AM
$this->form_validation->set_rules('question[que_(:num)][text]', 'lang:question_name', 'required|max_length[100]');
$this->form_validation->set_rules('question[(:num)][text]', 'lang:question_name', 'required|max_length[100]');
$this->form_validation->set_rules('question[(:num)][answer][ans_(:num)][weight]', 'lang:answer_weight', 'required|numeric');
$this->form_validation->set_rules('question[(:num)][answer][(:num)][weight]', 'lang:answer_weight', 'required|numeric');

Are you sure? I don’t see these working with the form_validation.

I want to validate the same. It’s request for next version of CI

 Signature 

Develop web, PDA applications.
My resume http://mdomansky.com/resume/

Contact with me )

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120588 Total Logged-in Users: 46
Total Topics: 126624 Total Anonymous Users: 2
Total Replies: 665662 Total Guests: 413
Total Posts: 792286    
Members ( View Memberlist )