mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +02:00
Add new $field->editUrl() method
This commit is contained in:
@@ -1394,6 +1394,26 @@ class Field extends WireData implements Saveable, Exportable {
|
||||
return $this->setTags($tagList, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL to edit field in the admin
|
||||
*
|
||||
* @param array|bool|string $options Specify array of options, string for find option, or bool for http option.
|
||||
* - `find` (string): Name of field to find in editor form
|
||||
* - `http` (bool): True to force inclusion of scheme and hostname
|
||||
* @return string
|
||||
* @since 3.0.151
|
||||
*
|
||||
*/
|
||||
public function editUrl($options = array()) {
|
||||
if(is_string($options)) $options = array('find' => $options);
|
||||
if(is_bool($options)) $options = array('http' => $options);
|
||||
if(!is_array($options)) $options = array();
|
||||
$url = $this->wire('config')->urls(empty($options['http']) ? 'admin' : 'httpAdmin');
|
||||
$url .= "setup/field/edit?id=$this->id";
|
||||
if(!empty($options['find'])) $url .= '#find-' . $this->wire('sanitizer')->fieldName($options['find']);
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* debugInfo PHP 5.6+ magic method
|
||||
*
|
||||
|
Reference in New Issue
Block a user