diff --git a/wire/core/Field.php b/wire/core/Field.php index cbc2a95a..2ca0b554 100644 --- a/wire/core/Field.php +++ b/wire/core/Field.php @@ -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 *