$this->add_fields([
+ //=== PERSONAL INFORMATION
+ Text::field('last-name', _x('Nom', 'Nom de famille', 'ccv')),
+ Text::field('first-name', __('Prénom', 'ccv')),
+ Text::field('profession', __('Profession', 'ccv')),
+ Text::field('city', __('Ville (département)', 'ccv')),
+ Text::field('country', __('Pays', 'ccv')),
+ Text::field('phone', __('Tel', 'ccv')),
+ Email::field('email', __('Email', 'ccv')),
+ Radio::field('sex', __('Sexe', 'ccv'))
+ ->options([
+ _x('M', 'Sexe (M)', 'ccv'),
+ _x('F', 'Sexe (F)', 'ccv'),
+ ]),
+ Text::field('age', __('Âge :', 'ccv')),
+ Textarea::field('message', __('Avez vous un message (ou une demande) spécifique à nous formuler ?', 'ccv'))->required(false),
+
+ // Special field: if a surgeon is selected, their e-mail address will be override the default delivery address
+ Select::field('surgeon', __('Chirurgien spécifique'))
+ ->required(false)
+ ->options([
+ 'Dr Guilhaume GENESTE' => 'dr.geneste@ccv-montpellier.fr',
+ 'Dr Grégory EDGARD-ROSA' => 'dr.edgard-rosa@ccv-montpellier.fr',
+ 'Dr Martin GRAU ORTIZ' => 'dr.grauortiz@ccv-montpellier.fr',
+ 'Dr Caroline HIRSH' => 'dr.hirsch@ccv-montpellier.fr',
+ ]),
+
+ //=== IMAGERY
+ // This is a special case and will be output manually so only using this for the e-mail label
+ Radio::field('imagery-type', __('Imagerie', 'ccv'))->required(false),
+ Textarea::field('imagery-online', __('Images en ligne', 'ccv'))->required(false), // Again, a manually handled field
+ Checkbox::field('imagery-posted', __('Images envoyé par courrier', 'ccv'))->required(false),
+
+ // Unique session identifier for uploads that go directly to CCV's NAS (upload.ccv-montpellier.fr)
+ // Made up of timestamp YYMMDDHHMM + nonce
+ Hidden::field('imagery-phone-token', __('ID sur le NAS', 'ccv'))->value(date('ymdHi') . '_'. wp_create_nonce('NAS-upload')),
+
//== SYMPTOMS
Radio::field('main-problem', __('Problème principal', 'ccv'))
->options([
Binary::field('infiltration', __('Infiltration ou thermocoagulation', 'ccv')),
Textarea::field('surgeries', __('Indiquez ici vos précédentes chirurgies de la colonne et leurs dates (le cas échéant)', 'ccv'))->required(false),
- //=== IMAGERY
- // This is a special case and will be output manually so only using this for the e-mail label
- Radio::field('imagery-type', __('Imagerie', 'ccv'))->required(false),
- Textarea::field('imagery-online', __('Images en ligne', 'ccv'))->required(false), // Again, a manually handled field
- Checkbox::field('imagery-posted', __('Images envoyé par courrier', 'ccv'))->required(false),
-
- // Unique session identifier for uploads that go directly to CCV's NAS (upload.ccv-montpellier.fr)
- // Made up of timestamp YYMMDDHHMM + nonce
- Hidden::field('imagery-phone-token', __('ID sur le NAS', 'ccv'))->value(date('ymdHi') . '_'. wp_create_nonce('NAS-upload')),
-
- //=== PERSONAL INFORMATION
- Text::field('last-name', _x('Nom', 'Nom de famille', 'ccv')),
- Text::field('first-name', __('Prénom', 'ccv')),
- Text::field('profession', __('Profession', 'ccv')),
- Text::field('city', __('Ville (département)', 'ccv')),
- Text::field('country', __('Pays', 'ccv')),
- Text::field('phone', __('Tel', 'ccv')),
- Email::field('email', __('Email', 'ccv')),
- Radio::field('sex', __('Sexe', 'ccv'))
- ->options([
- _x('M', 'Sexe (M)', 'ccv'),
- _x('F', 'Sexe (F)', 'ccv'),
- ]),
- Text::field('age', __('Âge :', 'ccv')),
- Textarea::field('message', __('Avez vous un message (ou une demande) spécifique à nous formuler ?', 'ccv'))->required(false),
-
- // Special field: if a surgeon is selected, their e-mail address will be override the default delivery address
- Select::field('surgeon', __('Chirurgien spécifique'))
- ->required(false)
- ->options([
- 'Dr Guilhaume GENESTE' => 'dr.geneste@ccv-montpellier.fr',
- 'Dr Grégory EDGARD-ROSA' => 'dr.edgard-rosa@ccv-montpellier.fr',
- 'Dr Martin GRAU ORTIZ' => 'dr.grauortiz@ccv-montpellier.fr',
- 'Dr Caroline HIRSH' => 'dr.hirsch@ccv-montpellier.fr',
- ]),
]);
}
public function pre_process() {
+
+ // If the user didn't select the NAS upload option, there's no point including the NAS ID in the form data
+ // NOTE: This relies on the value of the field so make sure it is always the same in both places (consultation.blade.php)
+ if ($this->get_data('imagery-type') !== __('Images téléversées depuis portable')) {
+ $this->remove_field('imagery-phone-token');
+ }
+
// If a surgeon is selected, send the form directly to them
$surgeons = $this->get_field('surgeon')->get_options();
if (!empty($this->get_data('surgeon')) && array_key_exists($this->get_data('surgeon'), $surgeons)) {