Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
[RELEASE] Release 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Jun 12, 2017
2 parents 42f2c0c + bffe4d1 commit 69d967b
Show file tree
Hide file tree
Showing 32 changed files with 548 additions and 235 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,38 @@
# ![FormZ](Documentation/Images/formz-icon@medium.png) FormZ - Changelog

1.1.1 - 2017-06-12
------------------

Contains two bug-fixes:

- **[[e225096](https://github.com/romm/formz/commit/e2250962f9ae92b5fa00876217e59d7f6a649f7a)] [BUGFIX] Fix nested field layouts not properly rendered**

This commit allows several field layouts level: a field rendered with the field view helper can now render another field within its slots.

Example:

```
<fz:field name="foo">
<fz:slot name="Field">
Bacon ipsum dolor...
<fz:field name="bar">
...
</fz:field>
</fz:slot>
</fz:field>
```

- **[[7da753a](https://github.com/romm/formz/commit/7da753ac0e7115dc84a5a964884051ca5c91ca84)] [BUGFIX] Fix layout/partial root paths not merged in field layouts**

This commit fixes the situation where a slot in a field layout tries to use a partial from the actual rendering context: until now only the partials configured in the FormZ view TypoScript configuration were supported, resulting in a fatal error.

The paths are now merged together, giving access to both of them.

The same behaviour is done for layouts.

- **[[9be619c](https://github.com/romm/formz/commit/9be619cf5ebdf567404203aaa748a066d413cc05)] [TASK] Mark form validation data functions as deprecated**

1.1.0 - 2017-04-08
------------------

Expand Down
5 changes: 4 additions & 1 deletion Classes/Form/FormInterface.php
Expand Up @@ -25,14 +25,17 @@
*/
interface FormInterface
{

/**
* @deprecated This method is deprecated and will be deleted in FormZ v2.
*
* @param string $key
* @return array
*/
public function getValidationData($key = null);

/**
* @deprecated This method is deprecated and will be deleted in FormZ v2.
*
* @param array $validationData
* @internal
*/
Expand Down
11 changes: 10 additions & 1 deletion Classes/Form/FormTrait.php
Expand Up @@ -13,6 +13,8 @@

namespace Romm\Formz\Form;

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* This trait should be used by default to implement all the functions required
* by the interface `FormInterface`.
Expand All @@ -22,7 +24,6 @@
*/
trait FormTrait
{

/**
* Contains the optional data returned from the validators of each field.
*
Expand All @@ -31,11 +32,15 @@ trait FormTrait
protected $validationData = [];

/**
* @deprecated This method is deprecated and will be deleted in FormZ v2.
*
* @param string $key
* @return array
*/
public function getValidationData($key = null)
{
GeneralUtility::logDeprecatedFunction();

$result = $this->validationData;

if (null !== $key) {
Expand All @@ -48,11 +53,15 @@ public function getValidationData($key = null)
}

/**
* @deprecated This method is deprecated and will be deleted in FormZ v2.
*
* @param array $validationData
* @internal
*/
public function setValidationData(array $validationData)
{
GeneralUtility::logDeprecatedFunction();

$this->validationData = $validationData;
}
}
62 changes: 62 additions & 0 deletions Classes/Service/ViewHelper/Field/FieldContextEntry.php
@@ -0,0 +1,62 @@
<?php
/*
* 2017 Romain CANON <romain.hydrocanon@gmail.com>
*
* This file is part of the TYPO3 FormZ project.
* It is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, either
* version 3 of the License, or any later version.
*
* For the full copyright and license information, see:
* http://www.gnu.org/licenses/gpl-3.0.html
*/

namespace Romm\Formz\Service\ViewHelper\Field;

use Romm\Formz\Configuration\Form\Field\Field;

class FieldContextEntry
{
/**
* @var Field
*/
protected $field;

/**
* @var array
*/
protected $options = [];

/**
* @param Field $field
*/
public function __construct(Field $field)
{
$this->field = $field;
}

/**
* @return Field|null
*/
public function getField()
{
return $this->field;
}

/**
* @param string $name
* @param mixed $value
*/
public function setOption($name, $value)
{
$this->options[$name] = $value;
}

/**
* @return array
*/
public function getOptions()
{
return $this->options;
}
}
Expand Up @@ -11,12 +11,13 @@
* http://www.gnu.org/licenses/gpl-3.0.html
*/

namespace Romm\Formz\Service\ViewHelper;
namespace Romm\Formz\Service\ViewHelper\Field;

use Romm\Formz\Configuration\Form\Field\Field;
use Romm\Formz\Configuration\View\Layouts\Layout;
use Romm\Formz\Core\Core;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;

/**
Expand All @@ -26,58 +27,55 @@
class FieldViewHelperService implements SingletonInterface
{
/**
* @var Field
*/
protected $currentField;

/**
* @var array
* Contains all current fields being rendered by FormZ: if a field is
* rendered beneath another field, several entries will be added to this
* property.
*
* @var FieldContextEntry[]
*/
protected $fieldOptions = [];
protected $contextEntries;

/**
* @var StandaloneView[]
*/
protected $view;

/**
* Reset every state that can be used by this service.
* Adds a new context entry to the entries array. The other field-related
* methods will be processed on this entry until the field rendering has
* ended.
*
* @param Field $field
*/
public function resetState()
public function setCurrentField(Field $field)
{
$this->currentField = null;
$this->fieldOptions = [];
$this->contextEntries[] = GeneralUtility::makeInstance(FieldContextEntry::class, $field);
}

/**
* Checks that the `FieldViewHelper` has been called. If not, an exception
* is thrown.
*
* @return bool
* Removes the current field context entry.
*/
public function fieldContextExists()
public function removeCurrentField()
{
return $this->currentField instanceof Field;
array_pop($this->contextEntries);
}

/**
* Returns the current field which was defined by the `FieldViewHelper`.
*
* Returns null if no current field was found.
* Checks that a field context is found.
*
* @return Field|null
* @return bool
*/
public function getCurrentField()
public function fieldContextExists()
{
return $this->currentField;
return false === empty($this->contextEntries);
}

/**
* @param Field $field
* @return Field
*/
public function setCurrentField(Field $field)
public function getCurrentField()
{
$this->currentField = $field;
return $this->getCurrentContext()->getField();
}

/**
Expand All @@ -86,15 +84,15 @@ public function setCurrentField(Field $field)
*/
public function setFieldOption($name, $value)
{
$this->fieldOptions[$name] = $value;
$this->getCurrentContext()->setOption($name, $value);
}

/**
* @return array
*/
public function getFieldOptions()
{
return $this->fieldOptions;
return $this->getCurrentContext()->getOptions();
}

/**
Expand All @@ -119,4 +117,12 @@ public function getView(Layout $layout)

return $this->view[$identifier];
}

/**
* @return FieldContextEntry
*/
protected function getCurrentContext()
{
return end($this->contextEntries);
}
}
Expand Up @@ -11,7 +11,7 @@
* http://www.gnu.org/licenses/gpl-3.0.html
*/

namespace Romm\Formz\Service\ViewHelper;
namespace Romm\Formz\Service\ViewHelper\Form;

use Romm\Formz\Behaviours\BehavioursManager;
use Romm\Formz\Exceptions\DuplicateEntryException;
Expand Down

0 comments on commit 69d967b

Please sign in to comment.