Webform的Twig命名约定

时间:2019-05-22 03:48:53

标签: webforms twig drupal-8

我正在使用Drupal8。我有一个名为Executed Executed cannot remove file4: no such file or directory stat: cannot stat 'file4': No such file or directory mv: cannot stat 'file4': No such file or directory Executed mv: cannot stat 'file4': No such file or directory File moved to recycle bin (机器名称)的Web表单。我需要为其创建一个树枝模板。我尝试使用#/bin/bash function directory(){ if [ ! -d ~/deleted ] then mkdir ~/deleted fi if [ ! -f ~/.restore.info ] then touch ~/.restore.info fi } function movefile(){ mv $1 ~/deleted/$1 echo "file moved to recycle bin" } function error_conditions(){ #prints error messages and checks if file is in project directory if [ ! -f ~/project ] then echo "cannot remove $filename: no such file or directory" elif [ -d ~/project ] then echo "cannot remove $filename: is a directory" else echo "missing operand" fi } function delete_file(){ #gets inode for filename inode=$(stat -c%i $filename) filename=$1 #pwd=$(readlink -e$filename) if $interactive then if [ $verbose = true ]; then read -p "Are you sure you want to delete $filename?" i_input if [ $i_input == "y" ] || [ $i_input == "Y" ] then mv $filename ~/delete/${filename}_inode echo ${filename}_$inode:$pwd>>~/.restore.info echo "$filename has been deleted" else echo "Nothing has been deleted" fi else read -p "Are you sure you want to delete $filename?" i_input if [ $i_input == "y" ] || [ $i_input == "Y" ]; then mv $filename ~/deleted/${filename}_$inode echo ${filename}_$inode:$pwd>>~/.restore.info else echo Aborted fi fi elif $verbose then mv $filename ~/deleted/${filename}_inode echo ${filename}_$inode:$inode:pwd>>~/.restore.info echo "$filename has been deleted." else mv $filename ~/deleted/${filename}_$inode echo ${filename}_$inode:$pwd>>~/.restore.info echo Executed fi } interactive=false verbose=false while getopts iv option do case $option in i) interactive=true;; v) verbose=true;; esac done shift $[OPTIND-1] for i in $* do filename=$i baseline=$(basename $i) if [ "$i" == "" ]; then echo "No filename provided" elif [ -d $filename ]; then if [ ! $recursive = true ]; then echo "Directory name provided, please provide a file" fi elif [ ! -f $filename ]; then echo "File does not exist" elif [ "$basefule" == "safe_rm" ] then echo "Attempting to delete safe_rm" else delete_file $filename fi done #################################M A I N############################### directory error_conditions $* delete_file $* movefile $* ,但对于Web表单根本没有任何意义。

1 个答案:

答案 0 :(得分:0)

使用hook_theme_suggestions_alter,您可以创建所需的任何模板建议。 例如:

function Yourtheme_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {

  if ($hook == 'form' & !empty($variables['element']['#id'])) {
    $suggestions[] = 'form__' . str_replace('-', '_', $variables['element']['#id']);
  }
}

然后您将在主题中创建模板,例如

form--user-register-form.html.twig

form--webform-submission-form-careeers-application.html.twig

您可以只使用建议,清除缓存后,其余的将由您完成。 您可以在模板中呈现元素。

例如:

<form{{ attributes }}>
  {{ element }}
</form>

附件: