This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Situation:
- Users have a OneToMany relationship to ProfDate Model
- UserController is extended to addTabFields with ProfDate Model form
- One of those tabbed fields is a dropdowns that depend on another field
Model:
class ProfDate extends Model
{
public $table = 'kurtjensen_profiledates_prof_dates';
protected $guarded = ['*'];
protected $fillable = ['defined_type'];
public $belongsTo = [
'user' => ['RainLab\User\Models\User',
'foreignKey' => 'user_id',
'parentKey'=>'id'],
];
Plugin.php
public function boot()
{
UserModel::extend(function($model){
$model->hasMany['profdate'] = ['KurtJensen\ProfileDates\Models\ProfDate',
'primaryKey' => 'user_id',
'localKey'=>'id'];
});
if (!post('_relation_field')){
UsersController::extendFormFields(function($form, $model, $context){
$form->addTabFields([
'profdate' => [
'label' => '',
'tab' => 'Dates',
'type' => 'partial',
'path' => '@/plugins/kurtjensen/profiledates/controllers/profdate/default.htm'
],
]);
});
}
}
Model\ProfDate.php
public function getDefinedTypeOptions($keyValue = null)
{ // Just some options as a filler
$options[''] = 'User Defined';
$options['birthday'] = 'Birth Date';
$options['hire'] = 'Hire Date';
$options['promotion'] = 'Promotion Date';
$options['certifcate'] = 'Certification Date';
return $options;
}
public function getLabelOptions($keyValue = null)
{ // Just some options as a filler
$options[''] = 'Dropdown depends on field above';
$options['birthday'] = 'Birth Date';
$options['hire'] = 'Hire Date';
$options['promotion'] = 'Promotion Date';
$options['certifcate'] = 'Certification Date';
return $options;
}
fields.yml
# ===================================
# Form Field Definitions
#
# ===================================
fields:
defined_type:
label: Type
type: dropdown
label:
label: Label
comment: What this date represents.
placeholder: Hired
type: dropdown
depends: defined_type
Expected behavior:
- Open Edit User and navigate to ProfDate Model list / tab
- Click "Add"
- Pop-up AJAX form shows for new record
- First field ( the one which another depends on ) is edited and focus changes
- AJAX Post happens to update the dependent field and refresh values and a circular wait symbol appears
- Result is returned with updated dependent field in Pop-up AJAX form to continue editing
Actual behavior:
- Open Edit User and navigate to ProfDate Model list / tab
- Click "Add"
- Pop-up AJAX form shows for new record
- First field ( the one which another depends on ) is edited and focus changes
- AJAX Post happens to update the dependent field and refresh values and a circular wait symbol appears
- Result is returned but Pop-up AJAX form does not reappear to continue entering a new record
Is this a bug or why is my form just disappearing when dependent field is being updated?
See short video: https://drive.google.com/file/d/0BwJLIChm8ILtNEdGanl5YW5pUHc/view?usp=sharing
Last updated
I think this has something to do with the popup loading indicator but I'm not sure. I will conduct some further testing and get back to you.
Hi,
I just found out why the modal will disappear because if the ajax found out that the response code is 2xx (200,201) it will tell that is success so what happen is that it will close the modal. 400 and 404 status code it will reappear the modal with an modal alert,message, for response code 406 it will reappear the modal.
Using the depends field option it will return 200. So I created an ajax that will call by the parent field and remove the depends option and there it solved my problem.
1-7 of 7