Skip to content
Permalink
Browse files

More specific default label for create forms

  • Loading branch information...
flack committed Oct 8, 2019
1 parent aa71cdd commit c3e146573457ac2df124ac312cb8b55bfdd8d952
Showing with 13 additions and 10 deletions.
  1. +6 −8 src/midcom/datamanager/datamanager.php
  2. +7 −2 src/midcom/datamanager/extension/type/toolbarType.php
@@ -26,6 +26,7 @@
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
use midcom\datamanager\storage\container\container;
use midcom\datamanager\storage\container\dbacontainer;
/**
* Experimental datamanager class
@@ -35,37 +36,31 @@ class datamanager
private $schemadb;
/**
*
* @var schema
*/
private $schema;
/**
*
* @var storage\container\container
*/
private $storage;
/**
*
* @var array
*/
private $defaults = [];
/**
*
* @var renderer
*/
private $renderer;
/**
*
* @var FormFactoryInterface
*/
private static $factory;
/**
*
* @var Form
*/
private $form;
@@ -243,15 +238,18 @@ public function get_form($name = null, $reset = false) : Form
'schema' => $this->get_schema()
];
$builder = self::get_factory()->createNamedBuilder($name, schemaType::class, null, $config);
$storage = $this->get_storage();
$config = [
'operations' => $this->schema->get('operations'),
'index_method' => 'noindex'
'index_method' => 'noindex',
'is_create' => $storage instanceof dbacontainer && empty($storage->get_value()->id)
];
$builder->add('form_toolbar', toolbarType::class, $config);
$this->form = $builder->getForm()
->setData($this->get_storage());
->setData($storage);
}
return $this->form;
}
@@ -24,7 +24,8 @@ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'operations' => [],
'mapped' => false
'mapped' => false,
'is_create' => false
]);
}
@@ -37,7 +38,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
foreach ($options['operations'] as $operation => $button_labels) {
foreach ((array) $button_labels as $key => $label) {
if ($label == '') {
$label = "form submit: {$operation}";
if ($operation == 'save' && $options['is_create']) {
$label = 'create';
} else {
$label = "form submit: {$operation}";
}
}
$attributes = [
'operation' => $operation,

0 comments on commit c3e1465

Please sign in to comment.
You can’t perform that action at this time.