Skip to content

Commit

Permalink
Merge 52d5ff8 into 310175a
Browse files Browse the repository at this point in the history
  • Loading branch information
TiSiE committed Jun 3, 2020
2 parents 310175a + 52d5ff8 commit 652d728
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 33 deletions.
19 changes: 10 additions & 9 deletions module/Organizations/src/Controller/IndexController.php
Expand Up @@ -55,19 +55,19 @@ class IndexController extends AbstractActionController
* @var Repository\Organization
*/
private $repository;

/**
* @var FormElementManagerV3Polyfill
*/
private $formManager;

private $viewHelper;

/**
* @var TranslatorInterface
*/
private $translator;

/**
* Create new controller instance
*
Expand All @@ -90,7 +90,7 @@ public function __construct(
$this->viewHelper = $viewHelper;
$this->translator = $translator;
}

/**
* Generates a list of organizations
*
Expand All @@ -114,8 +114,8 @@ public function indexAction()
]
]);
}


/**
* Change (Upsert) organizations
*
Expand Down Expand Up @@ -204,18 +204,19 @@ public function editAction()
} else {
if ($form instanceof SummaryForm) {
/* @var $form \Core\Form\SummaryForm */
$form->setRenderMode(SummaryForm::RENDER_SUMMARY);
$form->setRenderMode($isValid ? SummaryForm::RENDER_SUMMARY : SummaryForm::RENDER_FORM);
$viewHelper = 'summaryForm';
} else {
$viewHelper = 'form';
}

$content = $this->viewHelper->get($viewHelper)->__invoke($form);
}

return new JsonModel(
array(
'valid' => $isValid,
'errors' => $form->getMessages(),
'content' => $content,
)
);
Expand Down
60 changes: 50 additions & 10 deletions module/Organizations/src/Form/OrganizationsContactFieldset.php
Expand Up @@ -12,14 +12,15 @@

use Laminas\Form\Fieldset;
use Core\Entity\Hydrator\EntityHydrator;
use Laminas\InputFilter\InputFilterProviderInterface;
use Organizations\Entity\OrganizationContact;

/**
* Class OrganizationsContactFieldset
*
* @package Organizations\Form
*/
class OrganizationsContactFieldset extends Fieldset
class OrganizationsContactFieldset extends Fieldset implements InputFilterProviderInterface
{
/**
* Gets the Hydrator
Expand All @@ -42,7 +43,7 @@ public function getHydrator()
public function init()
{
$this->setName('contact');

$this->add(
array(
'name' => 'street',
Expand All @@ -51,7 +52,7 @@ public function init()
)
)
);

$this->add(
array(
'name' => 'houseNumber',
Expand All @@ -60,7 +61,7 @@ public function init()
)
)
);

$this->add(
array(
'name' => 'postalcode',
Expand All @@ -69,7 +70,7 @@ public function init()
)
)
);

$this->add(
array(
'name' => 'city',
Expand Down Expand Up @@ -104,13 +105,52 @@ public function init()
);
}

/**
* for later use - all the mandatory fields
* @return array
*/
public function getInputFilterSpecification()
{
return array();
return [
'street' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
'houseNumber' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
'postalcode' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
'city' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
'country' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
'phone' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
'fax' => [
'required' => false,
'filters' => [
['name' => 'StripTags']
],
],
];
}

/**
Expand Down
13 changes: 11 additions & 2 deletions module/Organizations/src/Form/OrganizationsDescriptionFieldset.php
Expand Up @@ -11,12 +11,13 @@

use Laminas\Form\Fieldset;
use Core\Entity\Hydrator\EntityHydrator;
use Laminas\InputFilter\InputFilterProviderInterface;

/**
* Class OrganizationsDescriptionFieldset
* @package Organizations\Form
*/
class OrganizationsDescriptionFieldset extends Fieldset
class OrganizationsDescriptionFieldset extends Fieldset implements InputFilterProviderInterface
{
public function getHydrator()
{
Expand Down Expand Up @@ -51,6 +52,14 @@ public function init()
*/
public function getInputFilterSpecification()
{
return array();
return [
'description' => [
'required' => true,
'allow_empty' => true,
'filters' => [
['name' => 'StripTags'],
],
],
];
}
}
28 changes: 16 additions & 12 deletions module/Organizations/src/Form/OrganizationsNameFieldset.php
Expand Up @@ -11,51 +11,48 @@
namespace Organizations\Form;

use Core\Repository\RepositoryService;
use Interop\Container\ContainerInterface;
use Laminas\Form\Fieldset;
use Core\Entity\Hydrator\EntityHydrator;
use Organizations\Entity\Hydrator\Strategy\OrganizationNameStrategy;
use Laminas\Form\FormElementManager\FormElementManagerV3Polyfill;
use Laminas\InputFilter\InputFilterProviderInterface;

/**
* Class OrganizationsFieldset
* @package Organizations\Form
*/
class OrganizationsNameFieldset extends Fieldset
class OrganizationsNameFieldset extends Fieldset implements InputFilterProviderInterface
{

/**
* @var RepositoryService
*/
private $repositories;

/**
* @return RepositoryService
*/
public function getRepositories()
{
return $this->repositories;
}

/**
* @param RepositoryService $repositories
*/
public function setRepositories($repositories)
{
$this->repositories = $repositories;
}

public function getHydrator()
{
if (!$this->hydrator) {
/* @var $formElementManager FormElementManagerV3Polyfill */
$hydrator = new EntityHydrator();
$formFactory = $this->getFormFactory();
$formElementManager = $formFactory->getFormElementManager();


$repositoryManager = $this->repositories;
$repOrganizationName = $repositoryManager->get('Organizations/OrganizationName');

$organizationName = new OrganizationNameStrategy($repOrganizationName);
$hydrator->addStrategy('organizationName', $organizationName);
$this->setHydrator($hydrator);
Expand Down Expand Up @@ -85,7 +82,14 @@ public function init()
*/
public function getInputFilterSpecification()
{
return array();
return [
'organizationName' => [
'required' => true,
'filters' => [
['name' => 'StripTags'],
],
],
];
}

/**
Expand Down

0 comments on commit 652d728

Please sign in to comment.