This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
reynierpm
I'm trying to use "Date Picker" widget as defined here and here but I'm doing something wrong since I get this error:
Trying to get property of non-object
/var/www/html/octproject.dev/modules/backend/classes/FormWidgetBase.php line 113
Type Exception
Undefined ErrorException
107 * supports nesting via HTML array.
108 * @return string
109 */
110 public function getLoadData()
111 {
112 list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom);
113 return $model->{$attribute};
114 }
115
116 /**
117 * Returns the final model and attribute name of
118 * a nested HTML array attribute.
119 * Eg: list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom);
This is what I'm doing for add the field on the plugin file:
UsersController::extendFormFields(function ($form, $model, $context) {
if (!$model instanceof UserModel)
return;
if (!$model->exists)
return;
// Ensures that a profile model always exists ...
ProfileModel::getFromUser($model);
$form->addTabFields([
'profile[pin]' => [
'label' => 'User PIN',
'tab' => 'Profile',
'type' => 'text'
],
'profile[pinRegeneratedDateTime]' => [
'label' => 'PIN set on',
'tab' => 'Profile',
'type' => 'Backend\FormWidgets\DatePicker', // tried with the registered alias name datepicker without success
'mode' => 'date'
],
'profile[phone2]' => [
'label' => 'Teléfono(2)',
'tab' => 'Profile',
'type' => 'text'
],
'profile[phone3]' => [
'label' => 'Teléfono(3)',
'tab' => 'Profile',
'type' => 'text'
],
'profile[phone4]' => [
'label' => 'Teléfono(4)',
'tab' => 'Profile',
'type' => 'text'
]
]);
});
I'm doing something wrong? Or this is not supported?
daftspunky
This error means the "profile" relation does not exist. It needs to be created otherwise the object reference is null.
1-2 of 2