dev-master
9999999-devForm input widget that let users creating validated uris.
BSD
The Requires
yii2 form widget
1.0.0
1.0.0.0Form input widget that let users creating validated uris.
BSD
The Requires
yii2 form widget
Form input widget that let users creating validated uris.
Url input widget for making uri strings in yii2 forms, (*1)
This module adds a new input field that can be used algonside another input text field to make valid uri strings. Also there is bundled in the package a UriValidator for both client side and server side validation., (*2)
Developed by Joseba JuĂĄniz (@Patroklo), (*3)
Spanish Readme version, (*4)
This is free software. It is released under the terms of the following BSD License., (*5)
Copyright (c) 2014, by Cyneek All rights reserved., (*6)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Cyneek nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission., (*7)
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE., (*8)
Install package via composer, (*9)
"cyneek/yii2-widget-urlparser": "dev-master"
Profit!, (*10)
In all this cases, by default, the input text field that holds the URI string will filter automatically all data that it's added with javaScript by making a valid string of characters. This has nothing to do with UriValidator, it's an additional filter added to increase the widget toughness., (*11)
This widget can be used in many ways, depending of it's definition options:, (*12)
echo \cyneek\yii2\widget\urlparser\UrlParser::widget([ 'model' => $model, 'attribute' => 'fieldName', 'source' => [ 'model' => $model, 'attribute' => 'sourceFieldName' ] ]);
Won't have client validation, also won't inherit any form or input changes made by the developer., (*13)
model (ActiveRecord or Model) (obligatory), (*14)
Defines the model that will be used to make the form input field., (*15)
attribute (string) (obligatory), (*16)
Defines the model attribute that will be used to make de form input field., (*17)
url_separator (char) (optional), (*18)
It's the character used to replace the space character while making a URI string. By default it's defined as "-" Warning If it's defined, the new value must also be a URI valid character., (*19)
regex_definition (char) (optional), (*20)
Regex that will be used to validate the inserted data in the URI field. In case it's not valid, it won't be added in it., (*21)
maxlength (integer) (optional), (*22)
Max number of characters that the field will allow., (*23)
source (array) (optional), (*24)
If source is defined, the widget will make an input text field that will be set as readonly, that's becase it will use the source field as root of its URI string data. Nevertheless, the widget will also include a button that will let the user to deactivate the readonly option of the field and the link between the two fields, letting him to introduce manually the data directly in the widget input field., (*25)
echo $form->field($model, 'fieldName')->widget('\cyneek\yii2\widget\urlparser\UrlParser', ['source' => ['model' => $model, 'attribute' => 'sourceFieldName']]);
It will have client validation if enabled at the form., (*26)
url_separator (char) (optional), (*27)
It's the character used to replace the space character while making a URI string. By default it's defined as "-" Warning If it's defined, the new value must also be a URI valid character., (*28)
source (array) (optional), (*29)
If source is defined, the widget will make an input text field that will be set as readonly, that's becase it will use the source field as root of its URI string data. Nevertheless, the widget will also include a button that will let the user to deactivate the readonly option of the field and the link between the two fields, letting him to introduce manually the data directly in the widget input field., (*30)
Additionally it has been included in the package a validation library for URI string data. Its main utility it's to verify the data sent via form and to ratify it as a valid / invalid URI string either from the Yii 2 php code or client javaScript., (*31)
Its use is identical as the UrlValidator, the only difference it's that, given the library it's not included by default in the system, you must include it manually in the Validator component, which is the responsible of storing all the active validators in the system. Usually this will be done in the rules method that holds the URI attribute that we want validated., (*32)
public function rules() { // adds UriValidator to the list of active validatos in the Validator component. Validator::$builtInValidators['uri'] = 'cyneek\yii2\widget\urlparser\validators\UriValidator'; return [ [['name', 'uriField'], 'required'], [['name'], 'string'], [['name', 'uriField'], 'safe'], [['uriField'], 'uri'] ]; }
From this moment, the validator will be active and functional for the system and can be used as any other default system validator., (*33)
Form input widget that let users creating validated uris.
BSD
yii2 form widget
Form input widget that let users creating validated uris.
BSD
yii2 form widget