class ButtonViewHelper extends AbstractFormFieldViewHelper (View source)

Creates a button.

= Examples =

Send Mail ``` Cancel ```

Properties

protected RenderingContextInterface $renderingContext from  AbstractViewHelper
protected ControllerContext $controllerContext

Controller Context to use

from  AbstractViewHelper
protected ObjectManagerInterface $objectManager from  AbstractViewHelper
protected LoggerInterface $logger from  AbstractViewHelper
protected bool $escapeOutput

Disable escaping of tag based ViewHelpers so that the rendered tag is not htmlspecialchar'd

from  AbstractTagBasedViewHelper
protected TagBuilder $tag

Tag builder instance

from  AbstractTagBasedViewHelper
protected string $tagName
protected PersistenceManagerInterface $persistenceManager from  AbstractFormViewHelper

Methods

void
setRenderingContext(RenderingContextInterface $renderingContext)

No description

void
injectObjectManager(ObjectManagerInterface $objectManager)

No description

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

void
injectTagBuilder(TagBuilder $tag)

No description

void
initialize()

Sets the tag name to $this->tagName.

void
registerTagAttribute(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null)

Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->initializeTag()

void
registerUniversalTagAttributes()

Registers all standard HTML universal attributes.

void
handleAdditionalArguments(array $arguments)

Handles additional arguments, sorting out any data- prefixed tag attributes and assigning them. Then passes the unassigned arguments to the parent class' method, which in the default implementation will throw an error about "undeclared argument used".

void
injectPersistenceManager(PersistenceManagerInterface $persistenceManager)

Injects the Flow Persistence Manager

string
prefixFieldName(string $fieldName)

Prefixes / namespaces the given name with the form field prefix

string
renderHiddenIdentityField(object $object, string $name)

Renders a hidden form field containing the technical identity of the given object.

void
registerFieldNameForFormTokenGeneration(string $fieldName)

Register a field name for inclusion in the HMAC / Form Token generation

void
initializeArguments()

Initialize the arguments.

string
getName()

Get the name of this form element.

getRequest()

Shortcut for retrieving the request from the controller context

string
getNameWithoutPrefix()

Get the name of this form element, without prefix.

mixed
getValueAttribute(bool $ignoreSubmittedFormData = false)

Returns the current value of this Form ViewHelper and converts it to an identifier string in case it's an object The value is determined as follows:

  • If property mapping errors occurred and the form is re-displayed, the last submitted value is returned
  • Else the bound property is returned (only in objectAccessor-mode)
  • As fallback the "value" argument of this ViewHelper is used

bool
hasMappingErrorOccurred()

Checks if a property mapping error has occurred in the last request.

mixed
getLastSubmittedFormData()

Get the form data which has last been submitted; only returns valid data in case a property mapping error has occurred. Check with hasMappingErrorOccurred() before!

void
addAdditionalIdentityPropertiesIfNeeded()

Add additional identity properties in case the current property is hierarchical (of the form "bla.blubb").

mixed
getPropertyValue()

Get the current property of the object bound to this form.

string
getPropertyPath()

Returns the "absolute" property path of the property bound to this ViewHelper.

bool
isObjectAccessorMode()

Internal method which checks if we should evaluate a domain object or just output arguments['name'] and arguments['value']

void
setErrorClassAttribute()

Add an CSS class if this view helper has errors

getMappingResultsForProperty()

Get errors for the property and form name of this view helper

void
renderHiddenFieldForEmptyValue()

Renders a hidden field with the same name as the element, to make sure the empty value is submitted in case nothing is selected. This is needed for checkbox and multiple select fields

string
render()

Renders the button.

Details

void setRenderingContext(RenderingContextInterface $renderingContext)

No description

Parameters

RenderingContextInterface $renderingContext

Return Value

void

void injectObjectManager(ObjectManagerInterface $objectManager)

No description

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

bool isEscapingInterceptorEnabled()

No description

Return Value

bool

__construct()

Constructor

void injectTagBuilder(TagBuilder $tag)

No description

Parameters

TagBuilder $tag

Return Value

void

void initialize()

Sets the tag name to $this->tagName.

Additionally, sets all tag attributes which were registered in $this->tagAttributes and additionalArguments.

Will be invoked just before the render method.

Return Value

void

protected void registerTagAttribute(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null)

Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->initializeTag()

Parameters

string $name

Name of tag attribute

string $type

Type of the tag attribute

string $description

Description of tag attribute

bool $required

set to true if tag attribute is required. Defaults to false.

mixed $defaultValue

Optional, default value of attribute if one applies

Return Value

void

protected void registerUniversalTagAttributes()

Registers all standard HTML universal attributes.

Should be used inside registerArguments();

Return Value

void

void handleAdditionalArguments(array $arguments)

Handles additional arguments, sorting out any data- prefixed tag attributes and assigning them. Then passes the unassigned arguments to the parent class' method, which in the default implementation will throw an error about "undeclared argument used".

Parameters

array $arguments

Return Value

void

void injectPersistenceManager(PersistenceManagerInterface $persistenceManager)

Injects the Flow Persistence Manager

Parameters

PersistenceManagerInterface $persistenceManager

Return Value

void

protected string prefixFieldName(string $fieldName)

Prefixes / namespaces the given name with the form field prefix

Parameters

string $fieldName

field name to be prefixed

Return Value

string

namespaced field name

protected string renderHiddenIdentityField(object $object, string $name)

Renders a hidden form field containing the technical identity of the given object.

Parameters

object $object

Object to create the identity field for

string $name Name

Return Value

string

A hidden field containing the Identity (UUID in Flow) of the given object or empty string if the object is unknown to the persistence framework

See also

Argument::setValue

protected void registerFieldNameForFormTokenGeneration(string $fieldName)

Register a field name for inclusion in the HMAC / Form Token generation

Parameters

string $fieldName

name of the field to register

Return Value

void

void initializeArguments()

Initialize the arguments.

Return Value

void

protected string getName()

Get the name of this form element.

Either returns arguments['name'], or the correct name for Object Access.

In case property is something like bla.blubb (hierarchical), then [bla][blubb] is generated.

Return Value

string Name

protected ActionRequest getRequest()

Shortcut for retrieving the request from the controller context

Return Value

ActionRequest

protected string getNameWithoutPrefix()

Get the name of this form element, without prefix.

Return Value

string name

protected mixed getValueAttribute(bool $ignoreSubmittedFormData = false)

Returns the current value of this Form ViewHelper and converts it to an identifier string in case it's an object The value is determined as follows:

  • If property mapping errors occurred and the form is re-displayed, the last submitted value is returned
  • Else the bound property is returned (only in objectAccessor-mode)
  • As fallback the "value" argument of this ViewHelper is used

Parameters

bool $ignoreSubmittedFormData

By default the submitted form value has precedence over value/property argument upon re-display. With this flag set the submitted data is not evaluated (e.g. for checkbox and hidden fields where the value attribute should not be changed)

Return Value

mixed Value

protected bool hasMappingErrorOccurred()

Checks if a property mapping error has occurred in the last request.

Return Value

bool

true if a mapping error occurred, false otherwise

protected mixed getLastSubmittedFormData()

Get the form data which has last been submitted; only returns valid data in case a property mapping error has occurred. Check with hasMappingErrorOccurred() before!

Return Value

mixed

protected void addAdditionalIdentityPropertiesIfNeeded()

Add additional identity properties in case the current property is hierarchical (of the form "bla.blubb").

Then, [bla][__identity] has to be generated as well.

Return Value

void

protected mixed getPropertyValue()

Get the current property of the object bound to this form.

Return Value

mixed Value

protected string getPropertyPath()

Returns the "absolute" property path of the property bound to this ViewHelper.

For this will be ".foo.bar" For this will be "foo.bar.baz"

Return Value

string

protected bool isObjectAccessorMode()

Internal method which checks if we should evaluate a domain object or just output arguments['name'] and arguments['value']

Return Value

bool

true if we should evaluate the domain object, false otherwise.

protected void setErrorClassAttribute()

Add an CSS class if this view helper has errors

Return Value

void

protected Result getMappingResultsForProperty()

Get errors for the property and form name of this view helper

Return Value

Result

protected void renderHiddenFieldForEmptyValue()

Renders a hidden field with the same name as the element, to make sure the empty value is submitted in case nothing is selected. This is needed for checkbox and multiple select fields

Return Value

void

string render()

Renders the button.

Return Value

string