2016-11-21 9 views
1

ユーザーアカウントページにフォーム選択入力を追加したい/ユーザーの追加ページに、オプション/値の動的リストを追加したい。Concrete5ユーザーアカウントの動的選択リスト/ユーザーの追加ページ

私はデータベーステーブルから動的リストを取得し、選択オプションの動的リストを作成する方法を知っています。

echo $form->select('clientsID', $indexed_array, '0'); 

質問:これをアカウント/追加ユーザーページに追加してこれをユーザーテーブルに保存する場所と方法を教えてください。

答えて

0

私はあなたがよく理解していればユーザ属性が必要です。 UserInfoに自動的に保存され、オプションを正しく設定すると、ユーザーアカウントページ/ユーザー追加ページに表示されます。

次のすべてのコードは、/application/controllersのコントローラファイル、またはパッケージ内の方が良いことに注意してください。パッケージを作成する方法はよく文書化されていますhere。そうすれば、サイトは問題なく更新できます。

ユーザー属性(この場合はドロップダウン)に充填されるDBテーブル、または他のソースから動的な値を使用して連想配列は:

$options = array(
    'foo' => 'Foo', 
    'bar' => 'Bar', 
    'baz' => 'Baz' 
); 

パラメータ属性:

$selectArgs = array(
    'akHandle' => 'my_select', 
    'akName' => t('my Select'), // t() is for translation 
    'uakProfileDisplay' => true, // Will be displayed on the Users Profile page 
    'uakMemberListDisplay' => true, // Will be displayed on the dashboard members page 
    'uakProfileEdit' => true, // A memeber is able to edit the attribute 
    'uakProfileEditRequired' => true, // The attribute MUST be filled with a value 
    'uakRegisterEdit' => true, // Will be displayed on the Register Page 
    'uakRegisterEditRequired' => true, // The attribute MUST be filled with a value upon registration 
    'akIsSearchableIndexed' => true, // The attribute will be indexed (searchable) 
    'akSelectAllowOtherValues' => false, // A user may add/remove other options to the select attribute 
    'akSelectOptionDisplayOrder' => 'alpha_asc', // the display order 
    'akIsSearchable' => true // one can search by these options 
); 

使用クラス:

use \Concrete\Core\Attribute\Type as AttributeType; 
use UserAttributeKey; 
use Concrete\Attribute\Select\Option; 

Defi NE属性タイプ:

$attrSelect = AttributeType::getByHandle('select'); 

チェック属性がすでに存在していない場合は、それを作成した場合:

$mySelect = UserAttributeKey::getByHandle($selectArgs['akHandle']) 

if(!is_object($mySelect)) { 
    UserAttributeKey::add($attrSelect, $selectArgs); 
    $mySelect = UserKey::getByHandle($args_address['akHandle']); 
} 

を最後にSELECT INTOオプションを入力します。

foreach($options as $value) { 
    Option::add($mySelect, t($value));   
} 
関連する問題