Class yii\gii\generators\form\Generator
Inheritance | yii\gii\generators\form\Generator » yii\gii\Generator » yii\base\Model |
---|---|
Available since version | 2.0 |
This generator will generate an action view file based on the specified model class.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$enableI18N | boolean | Whether the strings will be generated using Yii::t() or normal strings. |
yii\gii\Generator |
$messageCategory | string | The message category used by Yii::t() when $enableI18N is true . |
yii\gii\Generator |
$modelClass | yii\gii\generators\form\Generator | ||
$scenarioName | yii\gii\generators\form\Generator | ||
$template | string | The name of the code template that the user has selected. | yii\gii\Generator |
$templates | array | A list of available code templates. | yii\gii\Generator |
$viewName | yii\gii\generators\form\Generator | ||
$viewPath | yii\gii\generators\form\Generator |
Public Methods
Method | Description | Defined By |
---|---|---|
attributeLabels() | yii\gii\generators\form\Generator | |
autoCompleteData() | Returns the list of auto complete values. | yii\gii\Generator |
defaultTemplate() | Returns the root path to the default code template files. | yii\gii\Generator |
formView() | Returns the view file for the input form of the generator. | yii\gii\Generator |
generate() | Generates the code based on the current user input and the specified code template files. | yii\gii\generators\form\Generator |
generateString() | Generates a string depending on enableI18N property | yii\gii\Generator |
getDescription() | yii\gii\generators\form\Generator | |
getModelAttributes() | yii\gii\generators\form\Generator | |
getName() | yii\gii\generators\form\Generator | |
getStickyDataFile() | yii\gii\Generator | |
getTemplatePath() | yii\gii\Generator | |
hints() | Returns the list of hint messages. | yii\gii\generators\form\Generator |
init() | yii\gii\Generator | |
isReservedKeyword() | yii\gii\Generator | |
loadStickyAttributes() | Loads sticky attributes from an internal file and populates them into the generator. | yii\gii\Generator |
render() | Generates code using the specified code template and parameters. | yii\gii\Generator |
requiredTemplates() | Returns a list of code template files that are required. | yii\gii\generators\form\Generator |
rules() | yii\gii\generators\form\Generator | |
save() | Saves the generated code into files. | yii\gii\Generator |
saveStickyAttributes() | Saves sticky attributes into an internal file. | yii\gii\Generator |
stickyAttributes() | Returns the list of sticky attributes. | yii\gii\generators\form\Generator |
successMessage() | Returns the message to be displayed when the newly generated code is saved successfully. | yii\gii\generators\form\Generator |
validateClass() | An inline validator that checks if the attribute value refers to an existing class name. | yii\gii\Generator |
validateMessageCategory() | Checks if message category is not empty when I18N is enabled. | yii\gii\Generator |
validateNewClass() | An inline validator that checks if the attribute value refers to a valid namespaced class name. | yii\gii\Generator |
validateTemplate() | Validates the template selection. | yii\gii\Generator |
validateViewPath() | Validates $viewPath to make sure it is a valid path or path alias and exists. | yii\gii\generators\form\Generator |
Property Details
Method Details
public void attributeLabels ( ) |
Generates the code based on the current user input and the specified code template files.
This is the main method that child classes should implement. Please refer to yii\gii\generators\controller\Generator::generate() as an example on how to implement this method.
public yii\gii\CodeFile[] generate ( ) | ||
return | yii\gii\CodeFile[] | A list of code files to be created. |
---|
public string getDescription ( ) | ||
return | string | The detailed description of the generator. |
---|
public array getModelAttributes ( ) | ||
return | array | List of safe attributes of $modelClass |
---|
public string getName ( ) | ||
return | string | Name of the code generator |
---|
Returns the list of hint messages.
The array keys are the attribute names, and the array values are the corresponding hint messages. Hint messages will be displayed to end users when they are filling the form for the generator.
public array hints ( ) | ||
return | array | The list of hint messages |
---|
Returns a list of code template files that are required.
Derived classes usually should override this method if they require the existence of certain template files.
public array requiredTemplates ( ) | ||
return | array | List of code template files that are required. They should be file paths relative to \yii\gii\generators\form\templatePath. |
---|
Child classes should override this method like the following so that the parent rules are included:
return array_merge(parent::rules(), [
...rules for the child class...
]);
public void rules ( ) |
Returns the list of sticky attributes.
A sticky attribute will remember its value and will initialize the attribute with this value when the generator is restarted.
public array stickyAttributes ( ) | ||
return | array | List of sticky attributes |
---|
Returns the message to be displayed when the newly generated code is saved successfully.
Child classes may override this method to customize the message.
public string successMessage ( ) | ||
return | string | The message to be displayed when the newly generated code is saved successfully. |
---|
Validates $viewPath to make sure it is a valid path or path alias and exists.
public void validateViewPath ( ) |