/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $current_uri = \Drupal::request()->getRequestUri(); $path_args = array_slice(explode('/', $current_uri), -2, 2); $entry = array('co_degre' => $path_args[0], 'co_modu' => explode('?', $path_args[1])[0]); $module = BbCrudController::load('gbb_gmodu_plus', $entry); $form['infospasconvocform'] = array('#type' => 'text_format', '#title' => 'Infos à ne PAS porter sur la convocation', '#default_value' => $module[0]->convoc_info_off, '#description' => ''); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); return $form; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { // Ajouter un fichier $form['afile'] = array('#title' => t('Proposition'), '#type' => 'managed_file', '#upload_validators' => array('file_validate_extensions' => array('gif png jpg jpeg'), 'file_validate_size' => array(25600000)), '#upload_location' => 'private://images/', '#required' => FALSE); $form['submit_file'] = array('#type' => 'submit', '#value' => t('Submit')); // Supprimer un fichier $files = BbCrudController::load('gbb_file', ['co_modu' => '38967', 'co_degre' => '2', 'zone' => 3]); foreach ($files as $f) { $file_loaded = BbCrudController::load('file_managed', ['fid' => $f->fid]); // dpm($file_loaded); $flist[$f->fid] = $file_loaded[0]->filename; } $form['fileToDelete'] = array('#type' => 'radios', '#options' => $flist); $form['delete_file'] = array('#type' => 'submit', '#value' => t('Delete'), '#submit' => array('::deleteForm')); // $form['delete_file']['#submit'][] = 'delete_form'; return $form; }
public function sessionduplicate($co_degre, $co_modu, $sessid) { // load session informations $entry = array('sess_id' => $sessid); $session = BbCrudController::load('gbb_session', $entry); foreach ($session['0'] as $field => $val) { $tab[$field] = $val; } // kill unwanted informations unset($tab['sess_id']); unset($tab['denom_comp'], $tab['sigle']); unset($tab['nomu'], $tab['prenom']); // insert new row $DBWriteStatus = BbCrudController::create('gbb_session', $tab); $routeparameters = array('co_degre' => $co_degre, 'co_modu' => $co_modu); return $this->redirect('bb.moduleng', $routeparameters, array('fragment' => 'sessions')); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $sess_id = 1, $co_modu = 1, $co_degre = 2) { // get informations on session $entries = BbCrudController::load('gbb_session', ['sess_id' => $sess_id]); $lieu = BbCrudController::load('gbb_netab_dafor', ['co_lieu' => $entries[0]->co_lieu]); $entries[0]->denom_comp = $lieu[0]->denom_comp; $entries[0]->sigle = $lieu[0]->sigle; $resp = BbCrudController::load('gbb_gresp_dafor', ['co_resp' => $entries[0]->co_resp]); $entries[0]->nomu = $resp[0]->nomu; $entries[0]->prenom = $resp[0]->prenom; // On applique le theme session // voir HOOK_theme bb_theme dans module/custom/bb/bb.module $form['#theme'] = 'modal'; $form['#attributes'] = array('class' => array('pure-form', 'pure-form-stacked')); $form['sess_id'] = array('#type' => 'hidden', '#value' => $sess_id); $form['co_modu'] = array('#type' => 'hidden', '#default_value' => $entries[0]->co_modu); if ($sess_id == 1) { $form['co_modu']['#default_value'] = $co_modu; } $form['co_degre'] = array('#type' => 'hidden', '#default_value' => $entries[0]->co_degre); if ($sess_id == 1) { $form['co_degre']['#default_value'] = $co_degre; } $form['date'] = array('#type' => 'date', '#title' => t('Date'), '#default_value' => $entries[0]->date, '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-3-24'))); $form['horaires'] = array('#type' => 'textfield', '#title' => $this->t('Horaires'), '#default_value' => $entries[0]->horaires, '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-3-24'))); $form['lieu'] = array('#type' => 'search', '#title' => $this->t('Lieu'), '#default_value' => $entries[0]->sigle . " " . $entries[0]->denom_comp . " (" . $entries[0]->co_lieu . ")", '#autocomplete_route_name' => 'bb.autocomplete.lieu', '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-9-24'))); $form['formateur'] = array('#type' => 'textfield', '#title' => $this->t('Formateur'), '#default_value' => $entries[0]->nomu, '#default_value' => $entries[0]->nomu . " " . $entries[0]->prenom . " (" . $entries[0]->co_resp . ")", '#autocomplete_route_name' => 'bb.autocomplete.formateur', '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-9-24'))); $form['groupe'] = array('#type' => 'number', '#title' => $this->t('Groupe'), '#default_value' => $entries[0]->groupe, '#attributes' => array('min' => 1, 'max' => 99, 'step' => 1), '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-2-24'))); $form['duree_a_payer'] = array('#type' => 'textfield', '#title' => $this->t('DàP'), '#size' => 10, '#default_value' => $entries[0]->duree_a_payer, '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-2-24'))); $form['duree_prevue'] = array('#type' => 'textfield', '#title' => $this->t('DP'), '#size' => 10, '#default_value' => $entries[0]->duree_prevue, '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-2-24'))); $form['type_paiement'] = array('#type' => 'textfield', '#title' => $this->t('Type pmt'), '#default_value' => $entries[0]->type_paiement, '#attributes' => array('class' => array('pure-u-23-24')), '#wrapper_attributes' => array('class' => array('pure-u-1', 'pure-u-md-2-24'))); // Group submit handlers in an actions element with a key of "actions" so // that it gets styled correctly, and so that other modules may add actions // to the form. $form['actions'] = ['#type' => 'actions']; // Add a submit button that handles the submission of the form. $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->t('Submit'), '#submit' => array('::submitForm')]; return $form; }