Problem to get checkbox checked value from form

45 views
Skip to first unread message

Łukasz Probierz

unread,
Jan 18, 2015, 8:23:52 AM1/18/15
to agile-too...@googlegroups.com
Hi Group,

I'm using Agile Toolkit version ???? trying to ????? and I'm experiencing the following problem:




Hi,
I'm new into php, and this framework, but I like it by far.
Earlier work on java desktop apps.
I have some problem now...

Page with 3 columns
1. render sendet message
2. text to send with submit button (form)
3. list of maaaaany users where could you send msg from second column (form)


------------------------------------------------------------------------------------------------------------------------|
msg list column         | msg send column | user to send msg         |
------------------------------------------------------------------------------------------------------------------------|
| |  _ |
msg1 | -------------                 |       |_| user1 |
| |TEXT_AREA  |         | |
msg2 | |       |         |  _ |
| -------------                 |       |_| user1 |
msg3 | submin_btn | |
| | etc...         |


---------------------------------
populate column 3
---------------------------------
$form_user_list = $col_users->add('Form');
$model_users = $form_user_list->add('Model_User');
$model_users->addCondition('is_admin', 0);

foreach ($model_users as $user) {
$user_id = $user['id'];
$user_name = $user['name'];
$user_company = $user['company'];
$form_user_list->addField('Checkbox', $user_id, $user_name .'('.$user_company.')');
}
---------------------------------
sumbmit
---------------------------------
if($form_msg->isSubmitted()){
$form_msg->update();

foreach ($model_users as $user) {
$user_id = $user['id'];
$checkbox = $form_user_list->getElement($user_id); // how to get checbox obj?
// $user_id - i get ID
// $checkbox - object is null,  
$model_group->set('message_id', $model_form->get('id'));
$model_group->set('user_id', IF_CHECKBOX_CHECKED_GET_ID);
$model_group->save();
}
$form->js(null,$form->js()->_selector('.refresh_messages')->trigger('reload_page'))->univ()->successMessage('Msg send!')->closeDialog()->execute();
 }   
}

My question is:
1. how to get checkbox object from form?
2. I know JS pretty well and I can get all from checkbox ('checked' value),
but how can I pass 'user_id' and 'checked' from JS? 
Yes I know about ajax, but list of user is very long, pass it by URL?
3. Why older documentation of agile is deleted?
There was many usefull examples.

Thanks everyone!

Romans Malinovskis

unread,
Jan 20, 2015, 4:54:51 PM1/20/15
to agile-too...@googlegroups.com
HI  Lukasz

I suspect that using numeric name (2nd argument to addField) might not be working well. Try this

$form_user_list->addField('Checkbox', 'u_'.$user_id, $user_name .'('.$user_company.')');

and then

$checkbox = $form_user_list->getElement('u_'.$user_id); // how to get checbox obj?
Reply all
Reply to author
Forward
0 new messages