मैं अक्टूबरसीएमएस सीखने की कोशिश कर रहा हूं और मैं प्लगइन को विस्तारित करने की पूरी प्रक्रिया के बारे में उलझन में हूं। मैंने स्क्रीनकास्ट के अनुसार उपयोगकर्ता प्लगइन बढ़ाया है (https://vimeo.com/108040919)। आखिरकार, मैं "श्रेणी" नामक एक नया क्षेत्र बनाना चाहता हूं जो एक उपयोगकर्ता श्रेणी को स्टोर करता है। एक नए पृष्ठ पर, मेरे पास निम्न प्रपत्र है जिसे मैं अपने ई-मेल पते पर आधारित एक नया उपयोगकर्ता पंजीकृत करने के लिए उपयोग करने का प्रयास कर रहा हूं। "श्रेणी" उस पृष्ठ के आधार पर आबादी है जिसे उन्होंने पंजीकृत किया है और पासवर्ड स्वचालित रूप से जेनरेट किया जाना चाहिए ताकि उपयोगकर्ता इसे ई-मेल सक्रियण लिंक से अपने खाते की पुष्टि करने पर सेट कर सके। मेरी प्लगइन को "प्रोफाइल" कहा जाता है।अक्टूबरसीएमएस प्लगइन एक्सटेंशन से फ़ील्ड के साथ कस्टम उपयोगकर्ता पंजीकरण फॉर्म कैसे बनाएं
मेरे plugin.php फ़ाइल लगता है:
<?php namespace Sser\Profile\Models;
use Model;
use \October\Rain\Database\Traits\Validation;
/**
* Profile Model
*/
class Profile extends Model
{
public $rules = [
'category' => ['required', 'min:0']
];
/**
* @var string The database table used by the model.
*/
public $table = 'sser_profile_profiles';
/**
* @var array Guarded fields
*/
protected $guarded = ['*'];
/**
* @var array Fillable fields
*/
protected $fillable = [];
/**
* @var array Relations
*/
public $hasOne = [];
public $hasMany = [];
public $belongsTo = [
'user'=> ['RainLab\User\Models\User']
];
public $belongsToMany = [];
public $morphTo = [];
public $morphOne = [];
public $morphMany = [];
public $attachOne = [];
public $attachMany = [];
public static function getFromUser($user)
{
if($user->profile)
{
return $user->profile;
}
$profile = new static;
$profile->user = $user;
$profile->save();
$user->profile = $profile;
return $profile;
}
}
मैं एक उपयोगकर्ता पंजीकरण फार्म कि ऐसा दिखाई देता है बनाने के लिए कोशिश कर रहा हूँ:
<?php namespace Sser\Profile;
use System\Classes\PluginBase;
use RainLab\User\Models\User as UserModel;
use RainLab\User\Controllers\Users as UsersController;
use Sser\Profile\Models\Profile as ProfileModel;
/**
* Profile Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'Profile',
'description' => 'Handles user demographic information',
'author' => '',
'icon' => 'icon-leaf'
];
}
public function boot()
{
UserModel::extend(function($model){
$model->hasOne['profile'] = ['Sser\Profile\Models\Profile'];
});
// $user->profile->zip
UserModel::deleting(function($user) {
$user->profile->delete();
});
UsersController::extendFormFields(function($form,$model,$context){
if(!$model instanceof UserModel)
{
return;
}
if(!$model->exists)
{
return;
}
//Ensures that a profile model always exists...
ProfileModel::getFromUser($model);
$form->addTabFields([
'profile[age]'=>[
'label'=>'Age',
'tab'=>'Profile',
'type'=>'number'
],
'profile[gender]'=>[
'label'=>'Gender',
'tab'=>'Profile',
'type'=> 'dropdown',
'options'=>array('male'=>'Male',
'female'=>'Female')
],
'profile[category]'=>[
'label'=>'Category',
'tab'=>'Profile',
'type'=> 'dropdown',
'options'=>array('sink'=>'SINK',
'dink'=>'DINK')
],
'profile[vag]'=>[
'label'=>'VAG',
'tab'=>'Profile',
'type'=> 'dropdown',
'options'=>array('v'=>'V',
'a'=>'A',
'g'=>'G')
]
]);
});
}
}
मेरे profile.php फ़ाइल की तरह लग रहा
<form class="flexiContactForm col s12" role="form" data-request="{{ __SELF__ }}::onSignup" data-request-update="'{{ __SELF__ }}::confirm': '.confirm-container'">;
<button id="signup_button" class="waves-effect waves-light btn" style="float:right;" type="submit">Sign Up</button>
<div style="overflow: hidden; padding-right:0em;">
<input id="signup_email" type="email" class="validate" name="email">
<label id="signup_email_label" for="signup_email" data-error="" data-success="">Email Address</label>
<input type="hidden" name="category" value="{{ data.category }}"/>
</div>
</form>
मुझे इस बारे में उलझन में है कि कैसे "ऑन साइनअप" घटक बनाना है जो मूल रूप से ext उपयोगकर्ता प्लगइन्स "ऑन रजिस्ट्रार" घटक की कार्यक्षमता को समाप्त करें और फिर स्वचालित रूप से एक पासवर्ड उत्पन्न करें और "श्रेणी" फ़ील्ड को भी सहेजें। क्या कोई ऐसे पृष्ठ को उदाहरण या लिंक प्रदान कर सकता है जो इसका एक उदाहरण दिखाता है? धन्यवाद।