1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00

Some minor fixes to enable deleting a field that is missing its Fieldtype module. Plus addition of hasPage property to Inputfield modules. And a couple other minor things.

This commit is contained in:
Ryan Cramer
2017-07-07 14:03:39 -04:00
parent 5ec3e48de6
commit ae4761180f
5 changed files with 10 additions and 6 deletions

View File

@@ -813,6 +813,7 @@ class Field extends WireData implements Saveable, Exportable {
// just in case an Inputfield needs to know its Fieldtype/Field context, or lack of it // just in case an Inputfield needs to know its Fieldtype/Field context, or lack of it
$inputfield->set('hasFieldtype', $this->type); $inputfield->set('hasFieldtype', $this->type);
$inputfield->set('hasField', $this); $inputfield->set('hasField', $this);
$inputfield->set('hasPage', $page);
// custom field settings // custom field settings
foreach($this->data as $key => $value) { foreach($this->data as $key => $value) {

View File

@@ -177,7 +177,7 @@ class Fieldgroup extends WireArray implements Saveable, Exportable, HasLookupIte
* #pw-internal * #pw-internal
* *
* @param Field $field * @param Field $field
* @return bool * @return Fieldgroup $this
* *
*/ */
public function finishRemove(Field $field) { public function finishRemove(Field $field) {
@@ -194,7 +194,7 @@ class Fieldgroup extends WireArray implements Saveable, Exportable, HasLookupIte
* #pw-group-manipulation * #pw-group-manipulation
* *
* @param Field|string|int $field Field object, name or id. * @param Field|string|int $field Field object, name or id.
* @return bool * @return Fieldgroup $this
* *
*/ */
public function softRemove($field) { public function softRemove($field) {
@@ -612,7 +612,7 @@ class Fieldgroup extends WireArray implements Saveable, Exportable, HasLookupIte
if(!$inputfield) continue; if(!$inputfield) continue;
if($inputfield->collapsed == Inputfield::collapsedHidden) continue; if($inputfield->collapsed == Inputfield::collapsedHidden) continue;
$inputfield->value = $page->get($field->name); $inputfield->setAttribute('value', $page->get($field->name));
if($multiMode) { if($multiMode) {
$fieldInputfields[$field->id] = $inputfield; $fieldInputfields[$field->id] = $inputfield;

View File

@@ -161,7 +161,7 @@ class Fieldgroups extends WireSaveableItemsLookup {
throw new WireException("Field '$field' may not be removed from fieldgroup '{$item->name}' because it is permanent."); throw new WireException("Field '$field' may not be removed from fieldgroup '{$item->name}' because it is permanent.");
} }
$field->type->deleteTemplateField($template, $field); if($field->type) $field->type->deleteTemplateField($template, $field);
$item->finishRemove($field); $item->finishRemove($field);
} }
} }

View File

@@ -678,6 +678,8 @@ class Fields extends WireSaveableItems {
'getPageIDs' => false, 'getPageIDs' => false,
); );
if(!$field->type) return 0;
$options = array_merge($defaults, $options); $options = array_merge($defaults, $options);
$database = $this->wire('database'); $database = $this->wire('database');
$table = $database->escapeTable($field->getTable()); $table = $database->escapeTable($field->getTable());

View File

@@ -68,7 +68,8 @@
* @property string $requiredIf Optional conditions under which input is required (selector string). #pw-group-behavior * @property string $requiredIf Optional conditions under which input is required (selector string). #pw-group-behavior
* @property InputfieldWrapper|null $parent The parent InputfieldWrapper for this Inputfield or null if not set. #pw-internal * @property InputfieldWrapper|null $parent The parent InputfieldWrapper for this Inputfield or null if not set. #pw-internal
* @property null|bool|Fieldtype $hasFieldtype The Fieldtype using this Inputfield, or boolean false when known not to have a Fieldtype, or null when not known. #pw-group-other * @property null|bool|Fieldtype $hasFieldtype The Fieldtype using this Inputfield, or boolean false when known not to have a Fieldtype, or null when not known. #pw-group-other
* @property null|Field $hasField The Field object associated with this Inputfield, or or null when not applicable or not known. #pw-group-other * @property null|Field $hasField The Field object associated with this Inputfield, or null when not applicable or not known. #pw-group-other
* @property null|Page $hasPage The Page object associated with this Inputfield, or null when not applicable or not known. #pw-group-other
* @property bool|null $useLanguages When multi-language support active, can be set to true to make it provide inputs for each language, where supported (default=false). #pw-group-behavior * @property bool|null $useLanguages When multi-language support active, can be set to true to make it provide inputs for each language, where supported (default=false). #pw-group-behavior
* @property null|bool|int $entityEncodeLabel Set to boolean false to specifically disable entity encoding of field header/label (default=true). #pw-group-output * @property null|bool|int $entityEncodeLabel Set to boolean false to specifically disable entity encoding of field header/label (default=true). #pw-group-output
* @property null|bool $entityEncodeText Set to boolean false to specifically disable entity encoding for other text: description, notes, etc. (default=true). #pw-group-output * @property null|bool $entityEncodeText Set to boolean false to specifically disable entity encoding for other text: description, notes, etc. (default=true). #pw-group-output