Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make options hookable#321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
BernhardBaumrock wants to merge1 commit intoprocesswire:dev
base:dev
Choose a base branch
Loading
frombaumrock:make-options-hookable

Conversation

@BernhardBaumrock
Copy link
Contributor

Hey@ryancramerdesign I'm developing a new module with RockMigrations. To create an options field the migration looks like this:

<?phpnamespaceProcessWire;return ['type' =>'options','inputfieldClass' =>'InputfieldRadios','options' => [10 =>'a|automatic',20 =>'m|manually',  ],];

The problem is that I can not TRANSLATE option labels in this migration file for several reasons. This is not specific to options fields, but on all other fields I was able to translate labes notes and descriptions like this:

protectedfunctiontranslateField(HookEvent$event):void  {$f =$event->object;if (!$finstanceof Inputfield)return;$this->translate($f,'label');$this->translate($f,'notes');$this->translate($f,'description');// get fieldtype$type =$f->hasFieldtype;// translate optionsif ($typeinstanceof FieldtypeOptions) {$options =$type->getOptions($f->hasField);foreach ($optionsas$option) {$option->title =$this->x($option->title);      }// dumping options - titles are translated here!bd($options);$f->options =$options;    }  }

Unfortunately the field renders options with their original titles:

image

This missing hook has been a challenge for others (and myself) in the past:https://processwire.com/talk/topic/20321-add-custom-options-to-inputfieldselect-via-a-hook/

If there is a way to modify options of an options field already please let me know!

Otherwise thx for considering this PR :)

@BernhardBaumrockBernhardBaumrock changed the base branch frommaster todevJuly 9, 2025 08:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@BernhardBaumrock

[8]ページ先頭

©2009-2025 Movatter.jp