I have the following model:
class Model_GrantMinimal extends Model_Table {
public $table='grant';
function init() {
parent::init();
$this->hasOne('User');
$this->getField('id')->hidden(true);
$this->getField('user_id')->hidden(true);
$this->addField('grant_number');
$this->addField('grant_name');
}
}
And inside the page I have the following code:
$grant=$this->add('Model_GrantMinimal');
$grant->load($id);
$user=$grant->ref('user_id');
$field = $grantForm->addField('Dropdown','Manager');
$field->setModel($user);
$field
->validateNotNull()
->add('Icon',null,'after_field')
->set('arrows-left3')
->addStyle('cursor','pointer')
->js('click',$grantForm->js()->reload())
;
And everything works almost perfectly - how do I make sure the Dropdown ($field
in php) is linked to the overall form, i.e. when I change the value in the dropdown that value is passed into the $grantForm->onSubmit
- and how do I ensure the the defaultValue
(pre-selected value) of the dropdown is the User that is set by user_id
inside GrantMinimal
I'm loving the framework so far - its really impressive and coming from the .NET framework where MVVM and MVC are so common, specially with the latest WPF related. It has been a treat compared to the old way of writing HTML/PHP, just taking a while to fully understand whats what.