Manual:Hooks/AuthChangeFormFields/de-formal

From mediawiki.org
This page is a translated version of the page Manual:Hooks/AuthChangeFormFields and the translation is 36% complete.
AuthChangeFormFields
Available from version 1.27.0
AuthManager- 을 본따서 폼을 만드는 것을 허용 합니다.
Define function:
public static function onAuthChangeFormFields( $requests, $fieldInfo, &$formDescriptor, $action ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"AuthChangeFormFields": "MediaWiki\\Extension\\MyExtension\\Hooks::onAuthChangeFormFields"
	}
}
Called from: File(s): specialpage/AuthManagerSpecialPage.php
Interface: AuthChangeFormFieldsHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:AuthChangeFormFields extensions/de-formal.


상세 항목

  • $requests - AuthenticationRequests 의 나열되어 있는 항목들을 만들때 원본이 된 것은
  • $fieldInfo - 항목 정보 목록 ( AuthenticationRequest::getFieldInfo() 에 대한 모든 것의 모음).
  • &$formDescriptor - HTMLForm 내용설명 입니다. 특별키 weight 에 설정을 넣어 두면 항목들이 지적되는 순서를 변경할 수 있습니다.
  • $action - AuthManager::ACTION_* 의 설정값 종류의 어떤 것 입니다.

$formDescriptor 에 HTMLForm 을 정의(만들게)하는 내용이 들어 있을 겁니다(폼을 설명하는 것들 HTMLForm 생성자에게 전달 되려는 것); 돌발 처리(the hook) 는 보통의 진행 과정에 갑자기 변경을 가할 수 있게 합니다. The form field names (array keys) will match the field names in the requests. $fieldInfo is the result of AuthenticationRequest::mergeFieldInfo( $requests ).

Caveats:

  • Changing the requests is not allowed.
  • Adding fields which take data is not allowed (adding info fields is fine). Use an authentication provider's getAuthenticationRequests() method to add new fields.
  • Any validation, permission check or other business logic in the hook can be trivially circumvented by using the API. Business logic should be in the providers.
  • Any vital information must be made available via the API as well. If it's for users (e.g. the text of a CAPTCHA) use a null field in AuthenticationRequest::getFieldInfo() (which can be hidden/changed for the web UI from this hook if needed). If it's for machines (e.g. the public API key for the CAPTCHA) use AuthenticationRequest::getMetadata().

The hook is primarily meant to enhance fields defined by a provider in the same extension (e.g. change a textfield into a typeahead or other interactive widget), change the position of the widget and provide help links or other extra information. Changing form fields belonging to core or other extensions is allowed but should preferably be avoided as it makes the code more fragile.

See also