Skip to content
Snippets Groups Projects
Commit b5072db3 authored by Laurent's avatar Laurent
Browse files

dev #12992 #14706 custom fields

Values form: back button goes to instance edit action
parent 44b2855b
Branches
Tags
4 merge requests!321Dev#12992 custom fields,!302Dev#12992 Custom Fields,!235Dev#12992 Custom Fields,!228Dev#12992 Custom Fields
......@@ -86,7 +86,8 @@
$model_values = $model->find($model_id = $this->_getParam('id'));
if ($this->_request->isPost()) {
foreach ($this->_request->getPost() as $key => $value) {
$datas = $this->_request->getPost();
foreach ($datas as $key => $value) {
list($prefix, $custom_field_id) = explode('_', $key);
if (!$value_object = $model_values->getValueObject($custom_field_id))
$value_object = Class_CustomField_Value::newInstance([
......
......@@ -30,13 +30,16 @@ class Class_CustomField_Model {
protected
$_class_name,
$_label;
$_label,
$_edit_url;
public static function register($array_of_model_and_label) {
public static function register($array_of_models_configuration) {
static::$_models = [];
foreach ($array_of_model_and_label as $model => $label) {
static::$_models [$model]= (new Class_CustomField_Model($model, $label));
foreach ($array_of_models_configuration as $model => $configuration) {
static::$_models [$model]= (new Class_CustomField_Model($model,
$configuration['label'],
$configuration['edit_url']));
}
}
......@@ -52,9 +55,10 @@ class Class_CustomField_Model {
}
public function __construct($class_name, $label) {
public function __construct($class_name, $label, $edit_url) {
$this->_class_name = $class_name;
$this->_label = $label;
$this->_edit_url = $edit_url;
}
......@@ -72,6 +76,11 @@ class Class_CustomField_Model {
return $this->_label;
}
public function getEditUrl() {
return $this->_edit_url;
}
public function getId() {
return $this->_class_name;
......@@ -98,4 +107,4 @@ class Class_CustomField_Model {
return [];
}
}
?>
\ No newline at end of file
?>
......@@ -36,6 +36,13 @@ class Class_CustomField_ModelValues {
}
public function getEditURL() {
$url = $this->_model->getEditURL();
$url['id'] = $this->_real_instance->getId();
return $url;
}
public function getFields() {
return $this->_model->getFields();
}
......
......@@ -25,9 +25,22 @@ class ZendAfi_Controller_Plugin_CustomFields extends Zend_Controller_Plugin_Abst
public function preDispatch(Zend_Controller_Request_Abstract $request) {
Class_CustomField_Model::register(['Article' => $this->_('Article'),
'Formation' => $this->_('Formation'),
'UserGroup' => $this->_('Groupe d\'utilisateurs')]);
Class_CustomField_Model::register([
'Article' => ['label' => $this->_('Article'),
'edit_url' => ['module' => 'admin',
'controller' => 'cms',
'action' => 'newsedit']],
'Formation' => ['label' => $this->_('Formation'),
'edit_url' => ['module' => 'admin',
'controller' => 'formation',
'action' => 'edit']],
'UserGroup' => ['label' => $this->_('Groupe d\'utilisateurs'),
'edit_url' => ['module' => 'admin',
'controller' => 'usergroup',
'action' => 'edit']]
]);
}
}
?>
\ No newline at end of file
?>
......@@ -26,6 +26,8 @@ class ZendAfi_Form_Admin_CustomFields_ModelValues extends ZendAfi_Form {
public function setModel_Values($model_values) {
$this->_model_values = $model_values;
$this->setAttrib('data-backurl',
Class_Url::assemble($this->_model_values->getEditURL()));
}
public function init() {
......@@ -101,4 +103,4 @@ class Field_Strategy_select extends Field_Strategy {
}
}
?>
\ No newline at end of file
?>
......@@ -490,6 +490,11 @@ class CustomFieldsControllerValuesForUserGroupTeachersTest extends CustomFieldCo
public function statusSelectOptionDisabledShouldBeSelected() {
$this->assertXPath('//form//fieldset//select//option[@value="1"][@selected="selected"]');
}
/** @test */
public function backButtonShouldLinkToUsergroupsEditTeachers() {
$this->assertXPathContentContains('//div[contains(@onclick, "admin/usergroup/edit/id/1")]//td', 'Retour');
}
}
......@@ -504,7 +509,7 @@ class CustomFieldsControllerValuesForUserGroupPostTest extends CustomFieldContro
'field_3' => '1, menardeix', //address
'field_4' => 12, // age
'field_5' => 0, // status
'field_6' => 74000 //zip code
'field_6' => 74000, //zip code
]);
Class_CustomField_Value::clearCache();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment