protected function ManagedFileBase::elementName in Managed File 7
Prefix the "name" attribute.
$this->useElementParents = FALSE;
$this
->elementName();
// menu_image
$this
->elementName('upload_button');
// menu_image_upload_button
$this
->elementName('[fid]');
// menu_image[fid]
$this->useElementParents = TRUE;
$this
->elementName();
// options[menu_image]
$this
->elementName('upload_button');
// options_menu_image_upload_button
$this
->elementName('[fid]');
// options[menu_image][fid]
Parameters
string $suffix: The suffix of "name" attribute.
Return value
string Full value of the "name" attribute.
1 call to ManagedFileBase::elementName()
- ManagedFileBase::getFieldXpath in tests/
managed_file_base.test - Returns field XPath.
File
- tests/
managed_file_base.test, line 108 - Managed File Base (Test).
Class
- ManagedFileBase
- Class ManagedFileBase.
Code
protected function elementName($suffix = '') {
// Needed to split array values.
$glue = '_';
// Needed to separate parents and suffix.
$separator = '';
$this->useElementParents &= count($this->elementParents) > 1;
if ('' !== $suffix) {
// Get the first symbol of a suffix.
$symbol = substr($suffix, 0, 1);
$separator = $glue;
if ('[' === $symbol) {
// Split array values by "[".
$glue = $symbol;
// Remove first symbol from the suffix.
$suffix = ltrim($suffix, $symbol);
$separator = $this->useElementParents ? '][' : '[';
}
}
$name = ($this->useElementParents ? implode($glue, $this->elementParents) : end($this->elementParents)) . $separator . $suffix;
$this
->assert('debug', $name, 'Debug');
return $name;
}