/** * Sets the value to a field. * * @param string $value * @return void */ public function set_value($value) { $lastexception = null; // We want the editor to be ready, otherwise the value can not // be set and an exception is thrown. for ($i = 0; $i < behat_base::EXTENDED_TIMEOUT; $i++) { try { // Get tinyMCE editor id if it exists. if ($editorid = $this->get_editor_id()) { // Set the value to the iframe and save it to the textarea. $value = str_replace('"', '\\"', $value); $this->session->executeScript(' tinyMCE.get("' . $editorid . '").setContent("' . $value . '"); tinyMCE.get("' . $editorid . '").save(); '); } else { // Set the value to a textarea otherwise. parent::set_value($value); } return; } catch (Exception $e) { // Catching any kind of exception and ignoring it until times out. $lastexception = $e; // Waiting 0.1 seconds. usleep(100000); } } // If it is not available we throw the last exception. throw $lastexception; }
/** * Sets the value to a field. * * @param string $value * @return void */ public function set_value($value) { // Get tinyMCE editor id if it exists. if ($editorid = $this->get_editor_id()) { // Set the value to the iframe and save it to the textarea. $value = str_replace('"', '\\"', $value); $this->session->executeScript(' tinyMCE.get("' . $editorid . '").setContent("' . $value . '"); tinyMCE.get("' . $editorid . '").save(); '); } else { // Set the value to a textarea otherwise. parent::set_value($value); } }
/** * Sets the value to a field. * * @param string $value * @return void */ public function set_value($value) { $editorid = $this->field->getAttribute('id'); if ($this->running_javascript()) { $value = addslashes($value); $js = ' var editor = Y.one(document.getElementById("' . $editorid . 'editable")); if (editor) { editor.setHTML("' . $value . '"); } editor = Y.one(document.getElementById("' . $editorid . '")); editor.set("value", "' . $value . '"); '; $this->session->executeScript($js); } else { parent::set_value($value); } }