set a default saving data in a selection box in HABTM model
- by vincent low
here is my problem which in my system.
my system allow user to add event, which include date, time, places. In the other hand, user are allow to choose the "Event sharing to" some of other user. So i successful to created and share to other user, when the user login which are being choose to share with the event, he is able to view for that particular event.
But the problem is, when user add the event, he must choose for his own name also in the select box. If not he will be unable to read the event that he had created.
So i need to save a default data to my model, which is whenever the user got choose the sharing event or not, it also will save the data to his user id.
here is my code for select box, what can i edit and do to let it set a default saving value which is always save with the user own data??
input('User',array( 'label' = 'Select Related
Potential', 'options' = $users,
//'id'='user',
'style'='width:250px;height:100px',
//'selected' = $ownUserId )); ?
i try to solve by adding 1 more row to the add.ctp, but the permission just set to the own user who created it, the other user i choose is unable to read.
$form-input('User',array(
'label' = 'Select Related Potential',
'options' = $users, //'id'='user',
'style'='width:250px;height:100px',
'selected' = $ownUserId ));
$form-input('User',array('type'='hidden','value'=$ownUserId));